Home > front end >  limit device number vs UIDevice.current.identifierForVendor
limit device number vs UIDevice.current.identifierForVendor

Time:09-29

I am a junior professional software developer. I'm working on app with device limit per user, we use UIDevice.current.identifierForVendor for identifying device. Unfortunately we have problem with "device limit is reached" when installing and reinstalling app.

According to identifierForVendor documentation:

The value in this property remains the same while the app (or another app from the same vendor) is installed on the iOS device. The value changes when the user deletes all of that vendor’s apps from the device and subsequently reinstalls one or more of them.

The problem is obvious - after app is deleted and reinstalled we have a new identifierForVendor and we treat it as a new device.

According to another part of documentation:

Normally, the vendor is determined by data provided by the App Store. If the app was not installed from the app store (such as enterprise apps and apps still in development), then a vendor identifier is calculated based on the app’s bundle ID.

I have two questions:

  1. Problem accurs when we install app from Xcode or TestFlight. Would it appear also when we install app from AppStore?
  2. Is there any other way to limit device number and determine a device?

PS. I know, that there already were a few similar questions, bu in my opinion the answers were not exhaustive and it was a few years ago :)

CodePudding user response:

You can try to do it with Keychain:

  1. Generate UUID().uuidString
  2. Save it to Keychain with some of Keychain wrappers (e.g. KeychainAccess) using key "UniqueDeveiceID" or something.
  3. Send generated UUID to the server(or whatever)

As summary: After the app starts just check the value for the key UniqueDeveiceID exists. Keychain is not cleaning after reinstall so you'll have to chance to check if it's a reinstall or a newly registered device.

  • Related