Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get serial number of device using Xamarin Forms

Does anyone know how to retrieve a device's serial number using xamarin forms in C#?

I have researched a lot and tried some but could not get it work.

I am trying to develop a mobile application and publish to tablets for testing, so I would need to differentiate the devices, or anyone has other alternatives to share?

like image 616
Charis Avatar asked Sep 03 '25 10:09

Charis


1 Answers

You should use DependencyService to get it each platform.

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

For ios

you could refer to the blog 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.

Update :

from iOS 8, we cannot retrieve the serial number of our iDevice directly,if you want to get it,you could follow this

For Android,you could refer to this

like image 61
Leo Zhu - MSFT Avatar answered Sep 05 '25 01:09

Leo Zhu - MSFT