How to get Device Id in Xamarin Forms?

Srusti Thakkar picture Srusti Thakkar · May 8, 2018 · Viewed 22.4k times · Source

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"

Answer

Johannes picture Johannes · May 8, 2018

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.