Uniquely Identify a device in RMS 4.1

M Marcus Atkins 3 years 5 months ago
0 3 0

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.

Please Register or Login to post a reply

3 Replies

K Kutir Mobility

Marcus,
Have you tried response?

Visnupriya R
Kutir Mobility

B Bart Fukkink

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

J Jon Tara

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.

CONTACT
Can’t find what you’re looking for?