UDID Replacement in IOS7
Asked Answered
B

7

14

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.

Bethune answered 18/9, 2013 at 9:29 Comment(7)
try for device token.Provence
@Provence it changes when the device is wiped or contents of the device is erased.Bethune
you can't create UDID in iOS 7 check here in apple documentation developer.apple.com/library/ios/documentation/uikit/reference/…Week
@user2739931: Did you find out the solution?Punnet
@user2739931 I would be also interested as i need to identify which smartphone is accessing my enterprise appPeyter
@ZuzooVn Advertising identifier is best alternative for UDID. Negative is that if the user reset his settings which is ver unlikely it is the best alternative.Bethune
var identifierForVendor: NSUUID! { get }: 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. The value can also change when installing test builds using Xcode or when installing an app on a device using ad-hoc distribution. Therefore, if your app stores the value of this property anywhere, you should gracefully handle situations where the identifier changes.Goldfilled
B
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.

Bethune answered 12/4, 2014 at 5:14 Comment(2)
wrong decision, apple will reject your app. you may not use the advertising identifier for this purpose it is only allowed to be used for advertisement serving purpose.Hillie
I have already mentioned i'm going for enterprise distribution in the question partBethune
S
16

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.

Supersonics answered 18/9, 2013 at 9:33 Comment(7)
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.Retread
using above code this working for me that's why i put this as an answer and i also test it in to device after uninstall/reinstall.Supersonics
It could work, but only if you have other apps from the same vendor to keep the identifier stored on the device. If the user only has one app from a certain vendor, the identifier will change after a reinstall. Considering in most situations the latter is the case, it's not a very reliable replacement for UDIDRetread
@all Advertising Identifier will remain the same even when the app is uninstalled and re installed. But i will loose it when the phone contents are erased. Even with UIID its the same. Any other suggestion? or is there no alternative for this problem. I even tried Mac Address and it also has been removed in IOS7Bethune
@all Advertising Identifier will remain the same even when the app is uninstalled and re installed. But i will loose it when the phone contents are erased. Even with UIID its the same. Any other suggestion? or is there no alternative for this problem. I even tried Mac Address and it also has been removed in IOS7Bethune
@Nitin you could store uniqueIdentifier in keychain instead of user defaults.Cherice
My extension in this library supports 3 levels of persistence: github.com/sentryco/Telemetry/blob/main/Sources/Telemetry/util/…Paulinapauline
W
3

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

Week answered 11/10, 2013 at 6:11 Comment(0)
B
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.

Bethune answered 12/4, 2014 at 5:14 Comment(2)
wrong decision, apple will reject your app. you may not use the advertising identifier for this purpose it is only allowed to be used for advertisement serving purpose.Hillie
I have already mentioned i'm going for enterprise distribution in the question partBethune
R
2

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.

Resurrectionism answered 19/9, 2013 at 0:18 Comment(1)
@all Advertising Identifier will remain the same even when the app is uninstalled and re installed. But i will loose it when the phone contents are erased. Even with UIID its the same. Any other suggestion? or is there no alternative for this problem. I even tried Mac Address and it also has been removed in IOS7Bethune
A
1

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.

Arellano answered 20/8, 2014 at 16:45 Comment(0)
S
0

These blog posts by Ole should be helpful:

iOS 5: http://oleb.net/blog/2011/09/how-to-replace-the-udid/ iOS 6+: http://oleb.net/blog/2012/09/udid-apis-in-ios-6/

Sharpie answered 18/9, 2013 at 9:40 Comment(1)
@all Advertising Identifier will remain the same even when the app is uninstalled and re installed. But i will loose it when the phone contents are erased. Even with UIID its the same. Any other suggestion? or is there no alternative for this problem. I even tried Mac Address and it also has been removed in IOS7Bethune
C
0

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

var uniqueIdentifier: NSString!
uniqueIdentifier = UIDevice.currentDevice().identifierForVendor?.UUIDString
Cornett answered 7/6, 2016 at 11:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.