0

I want to generate a unique ID for every user when the user uses the app for the first time. The login happens in the backend and user need not enter mail id or mobile number etc. So what is the best way to ensure that an unique ID is generated for every user? Also if user uninstalls and installs the app again that particular user should not be treated as a new user. How do I handle this situation? Please help...

Thanks

Akshara
  • 141
  • 1
  • 11

2 Answers2

3

You should use UUID (not UDID). because as per apple guide line UDID can not use in coding. it will rejected by apple

But If use UUID than it will change after app will reinstall again. to solve this you have to save this UUID in keychain first time and have load from keychain every time you get

for this SSKeychain you can use.

You can make you unique key as well instead of UUID. that may be combination of your user detail like email and mobile num.

Shreyank
  • 1,549
  • 13
  • 24
0

You can do something like,

  NSUUID *myUUID = [[UIDevice currentDevice] identifierForVendor];
                NSLog(@"uuid is %@",[myUUID UUIDString]);
                NSString *deviceId = [myUUID UUIDString];

This will be unique.

Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75
  • Yes this is unique but it will change if app is uninstall and again install. So you need to store in keychain – Shreyank May 24 '16 at 06:36