Search code examples
xamarin.formsxamarin.iosxamarin.androidazure-notificationhubdeviceid

How to get Device Id in Xamarin Forms?


How can I get Device Unique Id in Android and iOS using c# in Xamarin Froms? I am using Azure Notification Hub for sending Notification. I am referring this blog. But in Android I am not able to find related "Settings"


Solution

  • According your posted blogpost http://codeworks.it/blog/?p=260 and your short problem description I try to answer your question.

    For android use Android.Provider.Settings.Secure.GetString(Android.App.Application.Context.ContentResolver, Android.Provider.Settings.Secure.AndroidId);

    For iOS see your blogpost.. or optionally save the IdentifierForVendor e.g. in your AppDelegate and return this value in your IOSDevice class (using the name in the blogpost). use UIDevice.CurrentDevice.IdentifierForVendor.ToString() to get the device ID on iOS.