IOS7中的UDID替换

UDID是否有替代方案我的应用程序在我正在使用企业分发时不会去App Store.那有什么替换我绑定广告标识符,打开udid,UIID和安全的UDID.但如果手机被重置,那么我将得到一个新的UDID.任何帮助将不胜感激.

解决方法

对于6.0以上的iOS,您可以使用identifierForvendor或CFUUIDRef.
-(Nsstring*)uniqID
{
    Nsstring* uniqueIdentifier = nil;
    if( [UIDevice instancesRespondToSelector:@selector(identifierForvendor)] ) {
        // iOS 6+
        uniqueIdentifier = [[[UIDevice currentDevice] identifierForvendor] UUIDString];
    } else {
        // before iOS 6,so just generate an identifier and store it
        uniqueIdentifier = [[NSUserDefaults standardUserDefaults] objectForKey:@"identifierForvendor"];
        if( !uniqueIdentifier ) {
            CFUUIDRef uuid = CFUUIDCreate(NULL);
            uniqueIdentifier = ( Nsstring*)CFUUIDCreateString(NULL,uuid);
            CFRelease(uuid);
            [[NSUserDefaults standardUserDefaults] setobject:uniqueIdentifier forKey:@"identifierForvendor"];
        }
    }
return uniqueIdentifier;
}//

UPDATE

正如Leon Lucardie所言,他是对的

identifierForvendor will change after app uninstall/reinstall. See here The value in this property remains the same while the app (or another app from the same vendor) is installed on the iOS device. The value changes when the user deletes all of that vendor’s apps from the device and subsequently reinstalls one or more of them.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...