identifierForVendor for UUIDString returns null

I have implemented push notification in my iPhone app and for device registration i used following code in the app.

[[[UIDevice currentDevice] identifierForVendor] UUIDString];

Above code works fine in the most of the devices. However, recently in some iPhone 5s devices with iOS 7.1 it returns null and due to this app crashes.


According to Apple documentation

If the value is nil, wait and get the value again later. This happens, for example, after the device has been restarted but before the user has unlocked the device

you can read it here: UIDevice

We have run into the same thing in our app, what we ended up using is

[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]

here's its reference: ASIdentifierManager

From experience, the identifier stays the same when reinstalling on the same device. I haven't discovered the pattern on when it changes, but it does... same as identifierForVendor.


由于这是一个老问题,我也面临同样的问题。所以我觉得在这里为其他人回答,如果他们遇到这个问题。

NSString *uid=[[UIDevice currentDevice] uniqueIdentifier];
NSLog(@"udd:%@",uid);
链接地址: http://www.djcxy.com/p/78502.html

上一篇: 使用D3.js的<circle>属性cx =“NaN”的值无效

下一篇: UUIDString的identifierForVendor返回null