簡體   English   中英

在iOS 8上獲取設備的序列號

[英]Get serial number of device on iOS 8

對於內部應用程序,我們使用以下代碼UIDevice + serialNumber來獲取設備序列號。 但是,似乎在iOS 8中,注冊表項“IOPlatformSerialNumber”為空。 序列號可以通過其他方式獲得嗎?

答:沒有。

目前有濫用.mobileconfig的浮動解決方案,但由於它們的性質,它們會增加其他問題。

UUID被移除是有原因的。 從2011年開始,查看美國Senat關於隱私和Apple召喚的消息,以了解為何必須更改。 http://arstechnica.com/apple/2011/04/apple-google-asked-to-join-judiciary-hearing-on-mobile-device-privacy/

濫用底層march端口以獲取設備序列號作為UUID的替換不是解決方案。 現在同樣濫用移動配置並猜測它將工作多長時間。

您有很多不錯的方法可以處理之前使用過設備識別的任何情況。 特別是在您擁有加密和MDM的企業環境中,絕對沒有必要跟蹤這樣的設備。

在iOS中不再可以直接檢索設備序列號。

但是,如果只是內部企業應用程序,我工作的公司要實現的是:

在設備配置期間,復制序列號並將設備名稱設置為序列號。

然后使用Apple的UIDevice API檢索設備名稱。

正如Helger所述,出於安全/隱私原因,iOS 6+中不再提供UDID。 相反,使用identifierForVendoradvertisingIdentifier請檢查UDID替換API

適用於iOS 8+

+ (NSString *)deviceUUID
{
if([[NSUserDefaults standardUserDefaults] objectForKey:[[NSBundle mainBundle] bundleIdentifier]])
    return [[NSUserDefaults standardUserDefaults] objectForKey:[[NSBundle mainBundle] bundleIdentifier]];

@autoreleasepool {

    CFUUIDRef uuidReference = CFUUIDCreate(nil);
    CFStringRef stringReference = CFUUIDCreateString(nil, uuidReference);
    NSString *uuidString = (__bridge NSString *)(stringReference);
    [[NSUserDefaults standardUserDefaults] setObject:uuidString forKey:[[NSBundle mainBundle] bundleIdentifier]];
    [[NSUserDefaults standardUserDefaults] synchronize];
    CFRelease(uuidReference);
    CFRelease(stringReference);
    return uuidString;
 }
}

您可以使用identifierForVendor將它們存儲到鑰匙串並稍后使用。 因為重新安裝應用程序時鑰匙串的價值不會改變。

我過去常常使用Open UDID 不知道它是否仍然有效。

Apple設備的序列號可在設置 - >常規 - >關於 - >序列號下找到。

暫無
暫無

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

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