iOS Question Device ID changing ?

marcick

Well-Known Member
Licensed User
Longtime User
I need to identify the devices where the app is installed, to enable/disable some functions basing on a licence structure (the app communicate to my server the device_id and get back a licence level).
In B4A it was easy reading the IMEI, here I have learned that the IMEI is not readable, so I found on this forum this method to get a "unique" device_id.

B4X:
Dim no As NativeObject   
no =no.Initialize("UIDevice").RunMethod("currentDevice", Null)
log(no.GetField("identifierForVendor").AsString)

What I see is that uninstalling the app, rebooting the phone and reinstalling it, that code change !
Is that possible or for sure I have a bug somewhere in my code ?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
In B4A it was easy reading the IMEI
Note that it becomes harder and harder with each version of Android. In Android 6 it is no longer possible to read the IMEI.

What I see is that uninstalling the app, rebooting the phone and reinstalling it, that code change !
This is the expected behavior. Once all apps from the same vendor are uninstalled the id is reset.

You can store a random string in KeyChain. It will be preserved.
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
Thanks Erel, I'll do like this, or accept that in case of uninstall/reinstall the licence need to be activated again.

If the app isn't uninstalled/reinstalled but just get and update from AppStore the id is not changed, true ?
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
Thanks Erel, I'll do like this, or accept that in case of uninstall/reinstall the licence need to be activated again.

If the app isn't uninstalled/reinstalled but just get and update from AppStore the id is not changed, true ?

I needed stg like this and i solved it as Erel said with keychain. With every app run you can check if keychain has a key of "deviceid" . If exists then you can retrieve the device id and device id will never change . If no key , it means that the app is being run for the first time. You can assign a random value between 1000000 and 9999999 and assign to device and put into keychain. If you even unistall the app , the key will remain at keychain. This is a perfect solution.
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
Thanks Tufanv.
Which would be the equivalent of Keychain for Android ? Because my solution is IMEI based I need to change something there also, before some user try my app on 6.0.
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
I dont know if there is a solution in android because when you uninstall at andorid it removes everything. I use imei for android and keychain for ios
Thanks Tufanv.
Which would be the equivalent of Keychain for Android ? Because my solution is IMEI based I need to change something there also, before some user try my app on 6.0.
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
btw, I'm asking if the reason they don't like we get access to a unique device identifier is because with that code we can publish a free app and then manage a way to ask money to the user (as I have intention to do). Again, I wonder if when we submit the app to the store they could have a deep look to the code and discover this.
 
Upvote 0
Top