簡體   English   中英

使用 Xamarin Forms 獲取設備序列號

[英]Get serial number of device using Xamarin Forms

有誰知道如何在 C# 中使用 xamarin.forms 檢索設備的序列號?

我已經研究了很多並嘗試了一些但無法讓它發揮作用。

我正在嘗試開發一個移動應用程序並發布到平板電腦上進行測試,所以我需要區分這些設備,或者有人有其他選擇可以分享嗎?

您應該使用DependencyService在每個平台上獲取它。

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

對於 ios

您可以參考博客或選擇將IdentifierForVendor保存在您的AppDelegate中,並在您的IOSDevice class 中返回此值(使用博文中的名稱)。 使用UIDevice.CurrentDevice.IdentifierForVendor.ToString()獲取 iOS 上的設備 ID。

更新

來自 iOS 8,我們無法直接獲取我們設備的序列號,如果你想得到它,你可以按照這個

Android可以參考這個

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM