Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I use identifierForVendor during development?

Apple recommends using [UIDevice currentDevice].identifierForVendor. The value of this changes every time one runs their application within the iOS simulator.

Initial functionality in my application requires that I recognize the device as a form of light authentication. This makes development tedious, and ideally I could persist a unique value across debug / run sessions. Are there any recommendations for accomplishing this?

like image 401
Jason Avatar asked Sep 19 '13 21:09

Jason


1 Answers

It's pretty clearly documented that this value will change when building and running in the simulator. On a real device, it will only change when the user deletes all of your apps from their device and reinstalls the app.

If you want the simulator app to use a consistent identifier during development you could define that UUID and use it for simulator builds only:

NSUUID *devId;
#if TARGET_IPHONE_SIMULATOR
devId = [NSUUID initWithUUIDString:@"SOME-STATIC-UUID-STRING"];
#else
devId = [UIDevice currentDevice].identifierForVendor;
#endif

Note that you need to replace SOME-STATIC-UUID-STRING with a real UUID string.

like image 120
RyanR Avatar answered Sep 18 '22 12:09

RyanR