2013-10-30 20 views
1

問題是,一旦我生成UUID它爲我工作。但如果我/用戶刪除應用程序比UUID是不一樣的,就像我以前生成的。如果我們使用uuid作爲標識符,這裏沒有唯一性。請幫我解決這個問題。如何重新安裝應用程序,如何獲得相同的uuid或任何字符串。 在此先感謝..是什麼在iOS上的複製品UDID或UUID 7

我使用這種方法:

NSString *udid; 

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) 
    udid = [UIDevice currentDevice].identifierForVendor.UUIDString; 
else 
    udid = [UIDevice currentDevice].uniqueIdentifier; 
+0

https://developer.apple.com/library/ios/documentation/uikit/reference/UIDevice_Class/時候才調用它參考文獻/ UIDevice.html#// apple_ref/occ/instp/UIDevice/identifierForVendor –

回答

2

首先,檢查NSHiplster http://nshipster.com/uuid-udid-unique-identifier/

這個非常豐富的職位這應該爲你工作:

NSString *UUIDString = nil; 
if ([[UIDevice currentDevice].systemVersion floatValue] >= 6.0) { 
    UUIDString = [[NSUUID UUID] UUIDString]; 
} else { 
    CFUUIDRef UUID = CFUUIDCreate(NULL); 
    UUIDString = CFBridgingRelease(CFUUIDCreateString(NULL, UUID)); 
} 
1

我已通過使用advertisingIdentifier解決了此問題。 鏈接:

https://developer.apple.com/library/ios/documentation/AdSupport/Reference/ASIdentifierManager_Ref/ASIdentifierManager.html#jumpTo_3

正如我所看到那裏advertisingIdentifier是

「的字母數字字符串唯一的每個設備,...」

對於我已經使用它作爲唯一標識符(儘管它用於 服務廣告)。

我的代碼是:

-(NSString*)UniqueAppId 
{ 
    NSString *Appname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]; 
    NSString *strApplicationUUID = [SSKeychain passwordForService:Appname account:@"manab"]; 
    if (strApplicationUUID == nil) 
    { 
     strApplicationUUID = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]; 
     [SSKeychain setPassword:strApplicationUUID forService:Appname account:@"manab"]; 
    } 
    return strApplicationUUID; 
} 

,需要爲

[self UniqueAppId]; 
+0

注意上面的鏈接''這個標識符可能會改變 - 例如,如果用戶擦除設備......「 – ghr

相關問題