0

My project have a case: one account user can only log on to one device ( if user log on to app in device A, user can't log on to app in device B). My Idea is: when user login, I'll get the imei Iphone (like android) and send it with request login to server. But I can't get imei. I try with UUID, but UUID will change when re install app. Keychain does not solve the problem. Please help me.

Tiny Dragon
  • 71
  • 2
  • 8
  • This is essentially a duplicate of [UIDevice uniqueIdentifier Deprecated - What To Do Now?](https://stackoverflow.com/questions/6993325/uidevice-uniqueidentifier-deprecated-what-to-do-now) – rmaddy Jun 03 '18 at 16:02
  • @rmaddy UUID will change when re install app. I can't use it. – Tiny Dragon Jun 03 '18 at 16:09
  • You need to make it work because Apple deliberately prevents 3rd party developers from having a device-level unique identifier. This is a good thing for users. – rmaddy Jun 03 '18 at 16:12
  • Rather than preventing the user from logging in on device B you should invalidate all existing sessions when the user logs in on a new device. It is better to respect the last login rather than the first. This way if the user gets a new device they don't need to go through any "unregistration" process. They may not be able to log out of the old device as they may have lost it. If the vendor identifier changes due to reinstall then again, you just invalidate the old session. – Paulw11 Jun 03 '18 at 20:41

2 Answers2

1

You have to use Keychain to store Unique Id , this will not change even if user delete app

You can use any wrapper Source code to do this

here is an example https://github.com/Joe0708/KeychainUUID

Abdelahad Darwish
  • 5,969
  • 1
  • 17
  • 35
  • If user delete keychain or not sync with Icloud. I think it not work – Tiny Dragon Jun 03 '18 at 16:23
  • 2
    Keychain currently persists across App re-installs but not if the device is wiped. This behaviour may change; it did in one of the iOS 10 betas, but I think Apple decided it would be too disruptive to existing apps that rely on the keychain persisting. That is not to say that the behaviour won't change in the future. – Paulw11 Jun 03 '18 at 20:43
1

At the beginning I'd like to mention that I do not know any method that directly answers your question, especially that Apple does not allow you to read IMEI and other similar stuff due to privacy concerns. This has been answered here.

The workaround might be as follows

Take a look at the UIDevice class, especially at the identifierForVendorProperty which provides you (according to documentation ) with a device specific value.

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.

As far as i know some financial apps are secured this way to permit only one device to access the account. This however requires registering a device each time application is reinstalled.

Alternatively you can use UUID you generate within your app (first run) and then you assign it for the user online. It might take the form similar to two step verification process. Be aware however that with such restrictions user will have to be online all the time to use your app.

grzebyk
  • 1,024
  • 1
  • 15
  • 26