iOS Dev Nugget 222 Uniquely Identifying User Devices


Need to run a code review on your codebase? Hire me

Sometimes you legitimately want to identify user iOS devices uniquely. You can use UIDevice's identifierForVendor for that. From the docs:

The value of this property is the same for apps that come from the same vendor running on the same device. A different value is returned for apps on the same device that come from different vendors, and for apps on different devices regardless of vendor.

However, the identifier value may change if all the apps under same developer account are deleted and reinstalled. One workaround is to store it in the Keychain. You want to be careful and set the item to be not synchronizable so you don't end up with the same identifier being assigned to every device owned by the same user.

Your feedback is valuable: Do you want more nuggets like this?   Yes   or   No



Like this and want such iOS dev nuggets to be emailed to you, weekly?

Sign Me Up! or follow @iosdevnuggets on Twitter


View archives of past issues