26

I've implemented this methods to get advertisingIdentifier and identifierForVendor:

- (NSString *) advertisingIdentifier
{
    if (!NSClassFromString(@"ASIdentifierManager")) {
        return [OpenUDID value];
    }
    return [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
}

- (NSString *) identifierForVendor
{
    if ([[UIDevice currentDevice] respondsToSelector:@selector(identifierForVendor)]) {
        return [[[UIDevice currentDevice] identifierForVendor] UUIDString];
    }
    return @"";
}

- (BOOL)isAdvertisingTrackingEnabled
{
    if (NSClassFromString(@"ASIdentifierManager") && ![[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]) {
        return NO;
    }
    return YES;
}

On simulator everything is working as should be and I can get the 2 strings IDs representation.

But when I run from iPhone 3GS with iOS 6.0 (10A403), these 2 methods return "00000000-0000-0000-0000-000000000000" as identifier. Already done:

  • Restarted the device
  • Removed the app and reinstalled
  • Created and Ad-Hoc build, installed, removed and installed again
  • Run this code from another app
  • Tested on iPad 2 with iOS 6.0 (10A403) and everything went ok (I've got the correct identifiers)
J. Costa
  • 7,442
  • 4
  • 26
  • 31

3 Answers3

25

It appears to be a bug in iOS. Seeing the same issue on devices that have been upgraded over-the-air, but devices upgraded with Xcode or iTunes work as expected without zeros.

Tried similar steps as you, and the only common theme was over-the-air (bad) versus tethered upgrade (good).

Update: Users that move directly from iOS 5.1 to 6.1 over-the-air experience a different behavior. Every time the app is closed completely and restarted, a new value is being returned by identifierForVendor. This would be expected if the app was being uninstalled and reinstalled, but that's not the case.

MattP
  • 1,920
  • 1
  • 15
  • 22
  • This appears to be correct as I've found after [searching](https://devforums.apple.com/search.jspa?resultTypes=MESSAGE&peopleEnabled=true&q=00000000-0000-0000-0000-000000000000) on Apple Forums (you need to login with your developer account) – J. Costa Sep 27 '12 at 07:52
  • 9
    It's pretty neat how Apple removed something (UID) and replaced it with something that *doesn't work*. – Glenn Maynard Oct 18 '12 at 19:59
  • 5
    We just updated a couple of devices to iOS 6.0.1 over-the-air and `identifierForVendor` appears to be fixed. – MattP Nov 01 '12 at 19:26
8

Apple confirmed this bug in their system in response to a Technical Support Incident request. They said that identifierForVendor and advertisingIdentifier sometimes returning all zeros can be seen both in development builds and apps downloaded over the air from the App Store. They have no work around and can't say when the problem will be fixed.

Ryan Bigg
  • 106,965
  • 23
  • 235
  • 261
Peter B. Kramer
  • 16,385
  • 1
  • 16
  • 20
  • Can you please post a link where I can see thier response, I had made advertisingIdentifier as a primary key and now its causing huge issues in my app – Geet Dec 19 '16 at 06:42
0

There are some situations where API returns empty response for ID like after device restore.

Suggestion is to postpone ID retreival, so you can call sometginh like this:

-(void)retrieveID
{
    if (<check fails>)
        [self performSelector:@"retrieveID" withObject:nil afterDelay:1.0];
}

And fetch ID later.

vedrano
  • 2,961
  • 1
  • 28
  • 25