Objective c nomore UDID-如何存储每个设备的推送通知设置?

Objective c nomore UDID-如何存储每个设备的推送通知设置?,objective-c,ios,xcode,udid,Objective C,Ios,Xcode,Udid,Udid已弃用-现在如何存储每个设备的推送通知设置 其他人如何存储每个设备的推送设置 我们可以使用iphone/ipad的MAC地址吗?还是苹果会禁止该应用程序?如下: @interface UIDevice (UIDeviceAppIdentifier) @property (readonly) NSString *deviceApplicationIdentifier; @end @implementation UIDevice (UIDeviceAppIdentifier) - (NSS

Udid已弃用-现在如何存储每个设备的推送通知设置

其他人如何存储每个设备的推送设置

我们可以使用iphone/ipad的MAC地址吗?还是苹果会禁止该应用程序?

如下:

@interface UIDevice (UIDeviceAppIdentifier)
@property (readonly) NSString *deviceApplicationIdentifier;
@end

@implementation UIDevice (UIDeviceAppIdentifier)
- (NSString *) deviceApplicationIdentifier
{ 
  static NSString *name     = @"a string identifying your application, like its name";
  NSUserDefaults  *defaults = [NSUserDefaults standardUserDefaults];  
  NSString        *value    = [defaults objectForKey: name];

  if (!value)
    {
      value = (NSString *) CFUUIDCreateString (NULL, CFUUIDCreate(NULL));    
      [defaults setObject: value forKey: name];
      [defaults synchronize]; // handle error
  }
  return value;
}
@end

iOS文档或多或少地描述了使用CFUUIDCreate()来创建标识符,并建议使用UserDefaults来存储它。

您可以尝试此项目


我投票结束这个问题,因为它是关于苹果的拒绝政策的。另见:。