Question

Is there is a alternative for UDID. My app will not be going to App Store as i'm using enterprise distribution. So is there any replacement. I tied advertising identifier, open udid, UIID and secure UDID. But if the phone is reset then i will get a new UDID. Any help would be appreciated.

Était-ce utile?

La solution 3

After trying all possible replacements. Advertising identifier is the best way to go. It remains same even after phone reset when i tested. If the user turn it off in the settings then we get a null value. Except for this hitch, this is the best replacement so far. Will update if i find any other better replacements.

Autres conseils

For above 6.0 iOS you can use identifierForVendor Or 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

As Leon Lucardie comment he is right

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.

You have to create vendor id then save it using keychain and get it back once you reset your phone using date time

check this link UUID and UDID for iOS7

Easy, Just use this code:

-(NSString *)getUID{
    if ([[UIDevice currentDevice] respondsToSelector:@selector(identifierForVendor)]) {
    // This is will run if it is iOS6 and above
        return [[[UIDevice currentDevice] identifierForVendor] UUIDString];
    } else {
    // This is will run before iOS6 and you can use openUDID or other
    // method to generate an identifier
        return [OpenUDID value];  
    }  
}

As you can understand, if you plan to support iOS 5 then you should use OpenUDID (Apple restrict reading the UDID even on iOS 5). With some answers here you would simply get rejected by Apple (my code has been approved in several apps of mine).

Pay attention that identifierForVendor would change if your user would remove the app (or all vendor apps if there are several) and reinstall.

I use the combination APNS token and vendorId. Both are checked to verify cellphone identity and I update them accordingly in cellphone and server when one of those change.

It´s still possible that both change, when the app is uninstalled and/or reset and stored for a few months, then both values would change.

This will cause that next time the cellphone gets the app installed, it will be identified as a new one.

Additional to this I run a process in server that marks as deleted any device which hadn't connected to the server for two months.

In that case user authentication is required and cellphone is added again to the customer's pool of devices.

I have only one app yet, but once I have the second one I might include advertisingId.

You can use after ios 6+ with Swift 2.2 version.

var uniqueIdentifier: NSString!
uniqueIdentifier = UIDevice.currentDevice().identifierForVendor?.UUIDString
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top