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?

5
  • 1
    Please always include a minimal reproducible example on what you have tried till now to help you better. stackoverflow.com/help/minimal-reproducible-example Commented Apr 15, 2020 at 3:24
  • 1
    I am not sure what do you mean by serial number! Commented Apr 15, 2020 at 5: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. Commented Apr 23, 2020 at 3:05
  • Could you get the device id by below method ? Commented Apr 28, 2020 at 5:46
  • @Charis If you want to get the hardware serial number,you could check the update below.I hope it works for you. Commented Apr 28, 2020 at 7:17

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.