-1

I am creating an ios app, since the udid is deprecated How can we uniquely identify the app.

jscs
  • 63,694
  • 13
  • 151
  • 195
Linda Thomas
  • 81
  • 1
  • 11
  • see this http://www.rogeriohirooka.com/2016/09/01/some-api-changes-on-ios-10/#udid – Anbu.Karthik Mar 07 '17 at 06:47
  • Can you please describe why you need this. You can randomly generate any unique string and can send it to your server and also can save it into your device,, everytime while calling any webservice, you can send that string to your server to uniquely identify that device, i dont understand why you need udid? – Mehul Thakkar Mar 07 '17 at 06:54

2 Answers2

1

You can use both UDID & UUID For UUID- let uuid = NSUUID().uuidString For UDID- let Identifier = UIDevice.current.identifierForVendor?.uuidString

ViralRathod
  • 324
  • 1
  • 3
  • 12
1

Below Code Generate Unique ID for device and IT IS UNIQUE upto you will RESET the device. Happy coding...:)

- (NSString *)createNewUUID {
    NSString *UUID = [[NSUUID UUID] UUIDString];
    return UUID;
}


//Check And Retrive UniqueIdentifier
-(void)checkAndGenerateUniqueIdentifier{

    //Retrive UDID
    NSString *retrieveuuid = [SSKeychain passwordForService:[[NSBundle mainBundle] bundleIdentifier] account:[[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleNameKey]];

    if (retrieveuuid == nil) {

        NSString *uuid = [self createNewUUID];
        NSLog(@" Create new uuid : %@",uuid);

        //Store the password in Keychain
        NSError *error = nil;

        [SSKeychain setPassword:uuid forService:[[NSBundle mainBundle] bundleIdentifier] account:[[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleNameKey] error:&error];

        if ([error code] == SSKeychainErrorNotFound) {
            NSLog(@"Password not found");
        }

    }

}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    //Check And Retrive UniqueIdentifier
    [self checkAndGenerateUniqueIdentifier];

    return YES;
}

Use Third party Keychain wrapper or iOS Keychain API for Store UUID.

Renish Dadhaniya
  • 10,642
  • 2
  • 31
  • 56