1

I have been working in a application and this application need to use a unique ID which is responsible to get connect with server to sync. If this ID would change, my application will lost the connection and all important data should be lost.

Right now I am using "identifierForVendor" but this seems not useful in some condition. Its getting changed in some condition which I mentioned below please check and give some suggestion to overcome from this issue.

"identifierForVendor" getting changed in the condition:

1) Delete app and then reinstalled again using different vendor (always).
2) Delete app and then reinstalled again using even same vendor (random).
3) iOS and xCode update (xCode-7.3/iOS-9.3)(not sure about frequency but on my last update its changed).

Please help me out.

tauheed
  • 161
  • 1
  • 12
  • Wait, what's the actual question? You actually answered your question (_Can `identifierForVendor` change?_). So I guess your actual question is something like _"What should I use instead?"_ That depends on your use-case. You need to post your requirements and design-goals so we can help you with that. – DarkDust May 02 '16 at 09:10

1 Answers1

1

Yes, identifierForVendor may change in some cases.

So, you can use SSKeychain to store your unique ID in KeyChain.

Import SSKeychain.h, SSKeychain.m, SSKeychainQuery.h and SSKeychainQuery.m files to your project.

add the Security.framework.

Save unique ID:

[SSKeychain setPassword:@"AnyID" forService:@"AnyService" account:@"AnyUser"]

Retrieve a unique ID:

NSString *UniqueID = [SSKeychain passwordForService:@"AnyService" account:@"AnyUser"];

Edit (as DarkDust suggested):

Download SSKeychain: https://github.com/soffes/SSKeychain

Ronak Chaniyara
  • 5,335
  • 3
  • 24
  • 51
  • That gist does not contain `SSKeychain`. [Here's the GitHub project.](https://github.com/soffes/SSKeychain) Since it supports CocoaPods, it's better to use that to keep up-to-date. – DarkDust May 02 '16 at 09:07
  • If I hard coded AnyID = aaa, AnyService = xxx, AnyUser = zzz, Will it be unique for each device? Will it be always same for the same device (does not matter any update of iOS or delete and again install the app)? – tauheed May 02 '16 at 10:40
  • Yes, does not matter any update of iOS or delete and again install the app@tauheed – Ronak Chaniyara May 02 '16 at 11:10
  • Also check [http://stackoverflow.com/questions/18911434/will-items-in-ios-keychain-survive-app-uninstall-and-reinstall](http://stackoverflow.com/questions/18911434/will-items-in-ios-keychain-survive-app-uninstall-and-reinstall) – Ronak Chaniyara May 02 '16 at 11:16
  • Thank you Ronak and DarkDust for your contribution. – tauheed May 02 '16 at 11:50
  • you are wc...enjoy coding!@tauheed – Ronak Chaniyara May 02 '16 at 12:00