5

I am creating a windows phone 8 app in phone gap + mobile jquery using visual studio 2012. I want to get the device token id from the device for push notifications. Can anyone guide me as to how can I get device token id of windows phone 8?

Eran
  • 387,369
  • 54
  • 702
  • 768
user2260989
  • 53
  • 1
  • 4

2 Answers2

5

You can use the DeviceExtendedProperties -

byte[] myDeviceID = (byte[])Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceUniqueId");
string idAsString = Convert.ToBase64String(myDeviceID);
Sahil Mittal
  • 20,697
  • 12
  • 65
  • 90
  • Please conform one more thing can i use deviceid as a device token id for push notification ? – user2260989 Aug 27 '13 at 07:20
  • I've not implemented Push notifications for windows phone. May be you could get help regarding this here: http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff402558%28v=vs.105%29.aspx – Sahil Mittal Aug 27 '13 at 08:51
  • 2
    Yes, you can, according to Microsoft. "It is also recommended that you pass the device ID to your cloud service so that the cloud service can track to which devices the URIs are assigned. If a URI changes, then the cloud service can replace the old URI for that device ID. Windows Phone does not provide a framework to do this, since in most scenarios apps and cloud services already have their own protocols that they use to communicate with each other." This is in the [MSDN documentation](http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202940(v=vs.105).aspx). – hotshot309 Aug 27 '13 at 14:39
1

For what reason you need the device ID? In Windows Phone 8 you need to get a Push Notification cannel, that is an URL that unique identify your app & device combination. Later you use that URL to send your Notification XML to the Microsoft Push Notification Services. You can take a look at how Notifications work here.

Josue Yeray
  • 1,163
  • 1
  • 11
  • 12