I need to uniquely identify a device. Is there a way yet as reading previous posts by people that there was no generic cross platform way of doing this without writing an extension to Rhomobile.
Any help will be much appreciated.
Uniquely Identify a device in RMS 4.1I need to uniquely identify a device. Is there a way yet as reading previous posts by people that there was no generic cross platform way of doing this without writing an extension to Rhomobile. Any help will be much appreciated. |
Subscribe to email updates
Monthly updates from our Zebra development team, straight to your inbox.
3 Replies
Marcus,
Have you tried response?
Visnupriya R
Kutir Mobility
Hey Marcus,
Maybe this code sample from our application helps:
# No id in settings, get it.
id = Rho::System.phoneId
# Or create one.
if( id.nil? || id.length == 0 )
id = [
sprintf( '%08x', rand( 0x100000000 ) ),
sprintf( '%04x', rand( 0x10000 ) ),
sprintf( '%04x', rand( 0x10000 ) ),
sprintf( '%04x', rand( 0x10000 ) ),
sprintf( '%012x', rand( 0x1000000000000 ) )
].join( '-' )
end
First we check our Settings table if we created an device id before. If this is not the case we try and get the phoneId provided by the System API. Should this one not be available aswell, then we create an unique one. An example of the created device id is: "d6bcde2b-7f8e-de32-7bc9-95f6345525f7"
After this code is executed, we save the id in the database, and the next time we get the saved value from the database.
This way you have an unique identifier (if it can find the phoneId, since that is hardware based) or an id that is created and is often unique, but it can differ through different application installs.
I hope this can help you a bit.
Bart
Note that iOS does not support the use of truly unique device IDs by apps. At one time it did. Currently, iOS supports per-app unique IDs. (Uninstalling and reinstalling the app, though, gets a new ID.)
Attempting to create your own (hardware-derived) unique ID will gamer a ban from the App Store if discovered by Apple.
That said, generating a random ID and sending it back to a database should satisfy Apple's requirements.