【发布时间】:2012-05-20 07:03:42
【问题描述】:
我正在尝试激活 APNS。因为uniqueIdentifier 已被弃用,所以我尝试使用CFUUIDCreate 和以下代码:
UIDevice *dev = [UIDevice currentDevice];
NSString *deviceUuid;
if ([dev respondsToSelector:@selector(uniqueIdentifier)])
deviceUuid = dev.uniqueIdentifier;
else {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
id uuid = [defaults objectForKey:@"deviceUuid"];
if (uuid)
deviceUuid = (NSString *)uuid;
else {
CFStringRef cfUuid = CFUUIDCreateString(NULL, CFUUIDCreate(NULL));
deviceUuid = (__bridge NSString *)cfUuid;
CFRelease(cfUuid);
[defaults setObject:deviceUuid forKey:@"deviceUuid"];
}
}
如何将uniqueIdentifier 替换为CFUUIDCreate?
【问题讨论】:
-
您需要的一切都应该在这里:stackoverflow.com/questions/6993325/…。下次尝试更多谷歌搜索。
-
我已经阅读了堆栈上的所有帖子。问题是:在这种情况下,我不知道如何实现
CFUUIDCreate。 -
我尝试编辑您的问题以将其与之前提出的问题区分开来,但不清楚您在问什么。你上面提供的代码有什么问题?它没有编译,还是没有按预期运行?
-
代码运行良好,但
uniqueIdentifier似乎已过时,我不想让我的应用程序被拒绝..
标签: ios uniqueidentifier