gekitz / UIDevice-with-UniqueIdentifier-for-iOS-5

Brings back the unique identifier support under iOS 5, it uses the device's mac address in combination with the bundle identifier to generate a new hashed unique identifier.
MIT License
1.24k stars 227 forks source link

[[UIDevice currentDevice] uniqueIdentifier] is global or local #3

Closed rodrigozanatta closed 13 years ago

rodrigozanatta commented 13 years ago

I never thought about it, but this old way is global for all app, or only for one bundle identifier app? You give us this 2 way :)

For making this noise, I give you this function (I can't sent by git because my "stupid" firewall). Your code give a identifier that don't look like the apple one. Is only put this code to solve:

- (NSString *)lookLikeUniqueIdentifier {
    NSString *code = [[NSString stringWithString:self] uppercaseString];
    return [NSString stringWithFormat: @"%@-%@-%@-%@-%@", 
            [code substringToIndex:8], 
            [code substringWithRange: NSMakeRange(8,4)], 
            [code substringWithRange:NSMakeRange(12,4)], 
            [code substringWithRange:NSMakeRange(16,4)],  
            [code substringFromIndex:20]];
}
gekitz commented 13 years ago

I give you 2 ways to access a global identifier.

The first one [[UIDevice currentDevice] uniqueDeviceIdentifier] is for one App only because it uses a mix of the bundle identifier + the mac address of the device.

The second one [[UIDevice currentDevice] uniqueGlobalDeviceIdentifier] is global, because it uses only the mac address.

The hash which is generated from both functions contains lower case letters, but that shouldn't be the problem. It doesn't mind if you use lower or uppercase letters, because you only want to track the device ;)

Hope that helps.

rodrigozanatta commented 13 years ago

Lol, Sory again. I only want to ask for you: when I use [[UIDevice currentDevice] uniqueIdentifier], the Apple way, it generate global or local.

I thought I have to use a device to test it, but no. The answer is: [[UIDevice currentDevice] uniqueIdentifier] = Global.. For any program, this will be the same.

So, you create a new way to identifier :)