0

我有一个应用程序,我在其中保存[[[UIDevice currentDevice] identifierForVendor] UUIDString]了这样的钥匙串:

NSString *bundleId = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];

NSString *strApplicationUUID;



if(![keychainItem objectForKey:(__bridge id)(kSecValueData)]){
        NSString *idfa = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
          NSLog(@"bundleId %@",idfa);
        [keychainItem setObject:idfa forKey:(__bridge id)(kSecValueData)];
        NSLog(@"saving item %@", [keychainItem objectForKey:(__bridge id)(kSecValueData)]);
         strApplicationUUID=[keychainItem objectForKey:(__bridge id)(kSecValueData)];
   }else{
        NSLog(@"saved item is %@", [keychainItem objectForKey:(__bridge id)(kSecValueData)]);

    strApplicationUUID=[keychainItem objectForKey:(__bridge id)(kSecValueData)];
    }

// NSString *strApplicationUUIDstr = [[NSString alloc] initWithData:[keychainItem objectForKey:(__bridge id)(kSecValueData)]
                                                 //encoding:NSUTF8StringEncoding];

NSLog(@"%@",strApplicationUUIDstr);
NSLog(@"%@",strApplicationUUID);

return strApplicationUUID;

但它总是给我零数据。它也不是第一次保存,有人可以帮我吗?

4

1 回答 1

0

由于 Apple 阻止使用 UDID,您的应用程序可能会被拒绝:-

愿它帮助你:

-(NSString *)getUniqueDeviceIdentifierAsString
{

 NSString *appName=[[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey];

 NSString *strApplicationUUID = [SSKeychain passwordForService:appName account:@"incoding"];
 if (strApplicationUUID == nil)
 {
    strApplicationUUID  = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
    [SSKeychain setPassword:strApplicationUUID forService:appName account:@"incoding"];
 }

 return strApplicationUUID;
}
于 2016-08-08T11:18:35.283 回答