为什么我的唯一设备ID会发生变化? [英] Why did my unique device ID change?

查看:1021
本文介绍了为什么我的唯一设备ID会发生变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下方法大约一个月没有问题。即使在卸载应用程序后,设备ID仍保持不变。最近我注意到我的设备ID已更改。我最近在Xcode6上做了很多应用程序的构建。这可能是一个原因吗?我希望我知道它何时改变了。它让我感到意外。当应用程序进入应用程序商店时,我有什么可担心的吗?也许这只是一个Xcode构建问题?我只是想找一种简单的方法来保证唯一的设备ID。我会使用advertisingIdentifer,但我听说将其用于其他目的,然后广告将被app store拒绝。以下是代码:

I have been using the following method for around a month with no problem. The device ID remained the same even after uninstalls of the app. Recently I noticed that my device ID changed. I have been doing a lot of builds of the app recently on Xcode6. Could this be a cause? I wish I knew exactly when it changed. It caught me by surprise. Do I have anything to worry about when the app goes on the app store? Maybe this is just an Xcode build problem? I am just looking for a simple way to guarantee a unique device ID. I would use advertisingIdentifer but I hear using it for purpose other then advertisements will get rejected by app store. Here is the code:

+ (NSString *)getUserID
{
    NSString *Appname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
    NSString *retrieveuuid = [SSKeychain passwordForService:Appname account:@"user"];

    if(retrieveuuid == NULL)
    {
        CFUUIDRef newUniqueId = CFUUIDCreate(kCFAllocatorDefault);
        retrieveuuid = (__bridge_transfer NSString*)CFUUIDCreateString(kCFAllocatorDefault, newUniqueId);
        CFRelease(newUniqueId);
        [SSKeychain setPassword:retrieveuuid forService:Appname account:@"user"];
    }

    NSLog(@"%@", retrieveuuid);
    return retrieveuuid;
}


推荐答案

唯一的设备ID没有坚持这已经被问过很多次了,你应该在这里找到一些好的信息。快速谷歌搜索会带来以下内容。

The unique device id does not persist This has been asked many times before and you should find some good info on here. A quick Google search brings up the following.

https://stackoverflow.com/search?q = iOS + UDID +替换

iOS 7的持久性UDID等价物?

UIDevice uniqueIdentifier已弃用 - 现在该怎么办?

iOS唯一用户标识符

一般建议是使用 CFUUID 创建你自己的 UUID ,然后将其保存在 keychain

general advice is to use CFUUID to create your own UUID, then persist it in the keychain

这篇关于为什么我的唯一设备ID会发生变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆