我在我的所有应用中使用[[UIDevice currentDevice] uniqueIdentifier]
,但是苹果不再允许使用uniqueIdentifier
。
我需要一些替代uniqueIdentifier
的东西,可以识别用户,即使用户删除应用程序并重新安装它,(还可以通过苹果审核)。
谢谢
我在我的所有应用中使用[[UIDevice currentDevice] uniqueIdentifier]
,但是苹果不再允许使用uniqueIdentifier
。
我需要一些替代uniqueIdentifier
的东西,可以识别用户,即使用户删除应用程序并重新安装它,(还可以通过苹果审核)。
谢谢
iOS 7及以下版本的更新:
+ (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;
}
您可以通过以下方式获取设备模型:
+ (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;
}
使用digipeople的hack。
修复它以避免应用程序崩溃。
systemId = [[NSUUID UUID] UUIDstring];