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?
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
eg 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.