I\'m using [[UIDevice currentDevice] uniqueIdentifier]
in all of my apps, Apple is not allowing the use of uniqueIdentifier
anymore.
I need somethi
Update for iOS 7 and prior:
+ (NSString *)uniqueDeviceIdentifier
{
NSString *device_id = nil;
if ([[self deviceModel] isEqualToString:@"Simulator iOS"]) {
// static id for simulator
device_id = @"== your random id ==";
}
else if (CurrentIOSVersion >= 6.f) {
// iOS 6 and later
device_id = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
}
else {
// iOS 5 and prior
SEL udidSelector = NSSelectorFromString(@"uniqueIdentifier");
if ([[UIDevice currentDevice] respondsToSelector:udidSelector]) {
device_id = [[UIDevice currentDevice] performSelector:udidSelector];
}
}
NSLog(@">>>>>> device_id: %@", device_id);
return device_id;
}
Device model you can receive through:
+ (NSString*)deviceModel
{
static NSString *device_model = nil;
if (device_model != nil)
return device_model;
struct utsname systemInfo;
uname(&systemInfo);
NSString *str = @(systemInfo.machine);
return device_model;
}
The documentation recommends what to do in this section.
Special Considerations
Do not use the uniqueIdentifier property. To create a unique identifier specific to your app, you can call the CFUUIDCreate function to create a UUID, and write it to the defaults database using the NSUserDefaults class.
To make sure that the unique identifier remains after you delete the app you should store it in the keychain rather than NSUserDefaults. Using the keychain you will also be able to share the same unique ID across all of your apps on the same device using keychain access groups. This approach will prevent you from incorrectly tracking users after the device is no longer theirs, and it will be available on any new iDevice they restore from backup.
with digipeople's hack.
Fix it to avoid app crash.
systemId = [[NSUUID UUID] UUIDstring];
http://developer.apple.com/library/mac/documentation/Foundation/Reference/NSUUID_Class/Reference/Reference.html#//apple_ref/occ/instm/NSUUID/UUIDString