0

After 1st May Apple is going to reject new apps and updates which are accessing to uniqueIdentifier. They introduced couple new methods in iOS 6.x which is good, but... what if I need my application run on older versions of SDK? So, my code would look like:

if ([UIDevice instancesRespondToSelector:@(identifierForVendor)]) {
     deviceId = [UIDevice currentDevice] identifierForVendor];
} else {
    // WHAT SHOULD BE HERE?
}

What should developers use if it is old SDK? Moreover, even if let's say I find something to use the value would be different once user upgrades his OS version, which is obviously bad - we would have two different ids for the same device.

iKiR
  • 860
  • 2
  • 8
  • 20
  • 1
    Well, `[[UIDevice currentDevice] uniqueIdentifier]`, perhaps? –  Apr 27 '13 at 19:27
  • @H2CO3 Apple will reject them. – Sulthan Apr 27 '13 at 19:29
  • Did you check http://stackoverflow.com/questions/6993325/uidevice-uniqueidentifier-deprecated-what-to-do-now – san Apr 27 '13 at 19:30
  • @H2CO3 it seems like that would still be rejected by apple – wattson12 Apr 27 '13 at 19:39
  • Well the whole problem is we have to have this if statement and it will return different values on different versions of iOS. I am pretty sure, that with uniqueIdentifier app will be rejected – iKiR Apr 27 '13 at 19:42
  • @iKiR CFUUIDCreate has been available since iOS 2.0 and has not been deprecated. see http://stackoverflow.com/questions/10555493/how-can-i-replace-uniqueidentifier-with-cfuuidcreate – wattson12 Apr 27 '13 at 19:54
  • @H2CO3 The whole point is Apple will use static analysis to check for `uniqueIdentifier`. They won't check if the call is inside some if. – Sulthan Apr 27 '13 at 19:59
  • @Sulthan, How do you know? From what I've heard they use more comprehensive methods, for example they look what symbols your app is using (linking with). – iKiR Apr 27 '13 at 20:18
  • @wattson12, yes I know and I know better (more persistent) solution, but what I am asking here is if Apple requires us to use new API, what is their recommendation for those who need support old SDK where new API is not available? If had to run only on > 6.0, I would just use identifierForVendor and wouldn't care – iKiR Apr 27 '13 at 20:20
  • 2
    @iKiR `uniqueIdentifier` was deprecated in iOS 5.0 already. The methods to replace it are widely known. You can create your own identifiers and save then to the keychain, for example. See the link @san mentioned above. – Sulthan Apr 27 '13 at 20:28
  • according to the first question linked in these comments, the recommendation was to use CFUUIDCreate (but I cant double check since that link seems to be dead) – wattson12 Apr 27 '13 at 20:28

1 Answers1

1

What should developers use if it is old SDK?

Apple won't accept apps built with an SDK that's more than a few versions old, so you may not have the option of using the SDK that you're thinking of. You can still set the minimum supported iOS version to older versions, but you probably won't be able to use -uniqueIdentifier even when running on pre-6.0 devices.

-[UIDevice uniqueIdentifier] has been deprecated since iOS 5.0, so you've had nearly 2 years to deal with the fact that it's going away. It's too late at this point to try to sneak in another update that uses the UDID; depending on what you do with the UDID you may have a problem. There are several good solutions for replacing the UDID that are within the spirit of the new rules, but again, the window for switching to them seamlessly is more or less closed.

even if let's say I find something to use the value would be different once user upgrades his OS version, which is obviously bad - we would have two different ids for the same device.

Consider the reason that the UDID was deprecated: users don't want you to be able to track their devices without their permission, and Apple surely doesn't want to be seen as enabling you to do it. So, if you do find a solution that works for you and which doesn't use the UDID, you might still risk rejection if your scheme doesn't allow the user to opt out of whatever tracking you're doing.

Community
  • 1
  • 1
Caleb
  • 124,013
  • 19
  • 183
  • 272