How can I get a unique device id?

4741
3
Jump to solution
03-23-2016 08:41 AM
KenGorton
Esri Contributor

Is there a way to obtain a unique ID for the device to add to the attributes of a data point? At first I thought AppFramework.device would provide this, but it is not constant from one app execution to the next.

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

Ken-

You can either write some logic to create your own unique ID and store it in QSettings, or if you are using AppStudio (which it looks like you are), you can use AppFramework's createId() method to get a unique ID, and store it in the settings with AppFramework's Settings. This should persist between sessions, but wouldn't be accessible between multiple apps (as iOS apps are sandboxed). Hopefully this gets you on the right track.

-Luke

View solution in original post

0 Kudos
3 Replies
LucasDanzinger
Esri Frequent Contributor

Ken-

You can either write some logic to create your own unique ID and store it in QSettings, or if you are using AppStudio (which it looks like you are), you can use AppFramework's createId() method to get a unique ID, and store it in the settings with AppFramework's Settings. This should persist between sessions, but wouldn't be accessible between multiple apps (as iOS apps are sandboxed). Hopefully this gets you on the right track.

-Luke

0 Kudos
MattFlowerday
New Contributor II

Hi Luke,

Any idea on what the AppFramework's createId() method actually does? I remember trying this and I'm pretty sure it creates a different id every time you run it, which means it isn't directly tied to that device. E.g. if you delete and re-install the app, you would never get the same id back - is that correct?

FYI for others, I asked a similar question in the AppStudio space:

How to query the device/computer type such as manufacturer?

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Matt,

createId() will create a unique ID every time it is invoked. So you would need to code some logic into your app so that if the Settings does not yet have an ID set, then to call this function, and set that ID. Else, it would not call the method, and just use the ID that has been already generated. However, you are correct that if the app was deleted, that it would not be tied to this ID.

0 Kudos