objective-cgoogle-analyticsios7flurryudid

Any other option to find iOS 7 UDID?


I would like to know about how to overcome with iOS 7 udid issue.

What we have tried: we have already implemented vendorUniqueID, well as Apple suggested it will be changed once user uninstall the app, thus is not good option.

Advertisement unique id is not an option; as Apple suggested that it is recommended to use for advertisement purpose only. As our app is not advertisement showcase app.

What we need know: we already have restoration id, is there a way to store that restoration ID such that it can be retrieved once the application is reinstalled.

I was wondering how the Google analytic' and Flurry analytic' are tracking.


Solution

  • You can do this by performing following steps.

    1) #import <Security/Security.h> in your project.

    2) Save your detail to keychain using SecItemAdd method.

    -(void) saveUsername:(NSString*)user withPassword:(NSString*)pass forServer:(NSString*)server {
    
        // Create dictionary of search parameters
        NSDictionary* dict = [NSDictionary dictionaryWithObjectsAndKeys:kSecClassInternetPassword,  kSecClass, server, kSecAttrServer, kCFBooleanTrue, kSecReturnAttributes, nil];
    
        // Remove any old values from the keychain
        OSStatus err = SecItemDelete((CFDictionaryRef) dict);
    
        // Create dictionary of parameters to add
        NSData* passwordData = [pass dataUsingEncoding:NSUTF8StringEncoding];
        dict = [NSDictionary kSecClassInternetPassword, kSecClass, server, kSecAttrServer, passwordData, kSecValueData, user, kSecAttrAccount, nil];
    
        // Try to save to keychain
        err = SecItemAdd((CFDictionaryRef) dict, NULL);
    
    }
    

    3) Get Stored data from keychain even if you have deleted an application.

    -(void) getCredentialsForServer:(NSString*)server {
    
        // Create dictionary of search parameters
        NSDictionary* dict = [NSDictionary dictionaryWithObjectsAndKeys:kSecClassInternetPassword,  kSecClass, server, kSecAttrServer, kCFBooleanTrue, kSecReturnAttributes, nil];
    
        // Look up server in the keychain
        NSDictionary* found = nil;
        OSStatus err = SecItemCopyMatching((CFDictionaryRef) dict, (CFDictionaryRef*) &found);
        if (!found) return;
    
        // Found
        NSString* user = (NSString*) [found objectForKey:kSecAttrAccount];
        NSString* pass = [[NSString alloc] initWithData:[found objectForKey:kSecValueData] encoding:NSUTF8StringEncoding];
        UIAlertView * alertView=[[UIAlertView alloc] initWithTitle:@"Key found" message:[NSString stringWithFormat:@"user : %@ pass :%@",user,pass] delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil] ;
        [alertView show];
        NSLog(@"user %@ : pass  %@", user,pass);
    
    }
    

    4) If you want to delete this attribute dictionary from keychain you can do that.

    -(void) removeAllCredentialsForServer:(NSString*)server {
    
        // Create dictionary of search parameters
        NSDictionary* dict = [NSDictionary dictionaryWithObjectsAndKeys:kSecClassInternetPassword,  kSecClass, server, kSecAttrServer, kCFBooleanTrue, kSecReturnAttributes, kCFBooleanTrue, kSecReturnData, nil];
    
        // Remove any old values from the keychain
        OSStatus err = SecItemDelete((CFDictionaryRef) dict);
    
    }