4

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?

KoalaBear
  • 2,755
  • 2
  • 25
  • 29
Charis
  • 111
  • 3
  • 11
  • 1
    Please always include a minimal reproducible example on what you have tried till now to help you better. https://stackoverflow.com/help/minimal-reproducible-example – Sathish Guru V Apr 15 '20 at 03:24
  • 1
    I am not sure what do you mean by serial number! – FreakyAli Apr 15 '20 at 05:26
  • @FreakyAli Hi, I am using android tablet. There is a serial number in Status under about device. I would like to get hold of it to differentiate the tablets I will need to publish my apk to. – Charis Apr 23 '20 at 03:05
  • Could you get the device id by below method ? – Leo Zhu Apr 28 '20 at 05:46
  • @Charis If you want to get the hardware serial number,you could check the update below.I hope it works for you. – Leo Zhu Apr 28 '20 at 07:17

1 Answers1

5

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

Leo Zhu
  • 15,726
  • 1
  • 7
  • 23