Apple since iOS7 ha deprecated and unavailable the use of the property -uniqueIdentifier
. The other properties -identifierForVendor
and -advertisingIdentifier
have the big problem that they change the value after uninstalling and reinstalling the app.
I need that value to identify uniquely the device connected to the server.
The app will be distributed only internally using an enterprise account, so no problem for the review process.
Is there a private a method to get it?
[UPDATE WITH SOME TEST]
As David said I used identifier for vendor on iOS7.1 device here are some results from my tests.
- After app installation: 28FD42B6-A993-4602-A988-69E375A1F913
- After killing the app: 28FD42B6-A993-4602-A988-69E375A1F913
- After deleting and reinstalling the app: 28FD42B6-A993-4602-A988-69E375A1F913
- After system restore and reinstalling the app: 4948F77F-3D41-4933-B2F0-C4DCB529C7CC
- After restore from backup made before system restore: 28FD42B6-A993-4602-A988-69E375A1F913
You should be able to use [UIDevice identifierForVendor]
for your purpose. According to the documentation:
The value of this property is the same for apps that come from the same vendor running on the same device.
Based on that I don't think the value should change if you delete and reinstall the application. Some quick testing confirms that it is persistent through delete/install cycles.
EDIT:
It looks like identifierForVendor
is only persistent through remove/install on iOS 7, so use uniqueIdentifier on iOS 6 and identifierForVendor on iOS 7 as:
@implementation UIDevice (persistentDeviceIdentifier)
-(NSString*)persistentDeviceIdentifier
{
if([self respondsToSelector:@selector(uniqueIdentifier)])
return [self performSelector:@selector(uniqueIdentifier)];
else
return [[self identifierForVendor] UUIDString];
}
@end
来源:https://stackoverflow.com/questions/22515222/ios-7-access-uuid-value-in-an-enterprise-application-not-for-appstore