简体   繁体   English

使用 Xamarin Forms 获取设备序列号

[英]Get serial number of device using Xamarin Forms

Does anyone know how to retrieve a device's serial number using xamarin.forms in C#?有谁知道如何在 C# 中使用 xamarin.forms 检索设备的序列号?

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.您应该使用DependencyService在每个平台上获取它。

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

For ios对于 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).您可以参考博客或选择将IdentifierForVendor保存在您的AppDelegate中,并在您的IOSDevice class 中返回此值(使用博文中的名称)。 use UIDevice.CurrentDevice.IdentifierForVendor.ToString() to get the device ID on iOS.使用UIDevice.CurrentDevice.IdentifierForVendor.ToString()获取 iOS 上的设备 ID。

Update :更新

from iOS 8, we cannot retrieve the serial number of our iDevice directly,if you want to get it,you could follow this来自 iOS 8,我们无法直接获取我们设备的序列号,如果你想得到它,你可以按照这个

For Android,you could refer to this Android可以参考这个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM