How to get unchanged device identifier from ios7 device programmatically

I need to get a unique device id to populate a unique user id in the database. For this, I used the following code.

NSString *strApplicationUUID= [[[UIDevice currentDevice] identifierForVendor] UUIDString];

But when I reinstall the application, the UUID changes all the time. But as far as I know, the device ID never changes. To do this, I used the third-party code below SSKeychainto save and retrieve the old UDID:

NSString *Appname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
    NSString *strApplicationUUID = [SSKeychain passwordForService:Appname account:@"manab"];
    if (strApplicationUUID == nil)
    {
        strApplicationUUID  = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
        [SSKeychain setPassword:strApplicationUUID forService:Appname account:@"manab"];
    }

Now the problem is when the version of this application is changed. Application v2.0 for application v1.0, and then the UDID has changed. So, the logic is clear to me that I do not get a unique UDID all the time, I just get a UDID as a provider or application database.

? , , .

+3
3

, advertIdentifier.

,

"- , ,..."

( ).

:

-(NSString*)UniqueAppId
{
    NSString *Appname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
    NSString *strApplicationUUID = [SSKeychain passwordForService:Appname account:@"manab"];
    if (strApplicationUUID == nil)
    {
        strApplicationUUID  = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
        [SSKeychain setPassword:strApplicationUUID forService:Appname account:@"manab"];
    }
    return strApplicationUUID;
}

[self UniqueAppId];
+6

advertisingIdentifier - , .

reset , .

UDID iOS 6 iOS 7

CFUUID Vs. Vs. identifierForVendor

. , , .: -)

+1

Objective-c

u IOS 7 , :

first create your own unique identifier and you have to save it in the keychain . Now use the provider ID , this will reset if all applications of the same provider are removed from the device.

0
source

All Articles