1

I am developing an Android app (and soon iPhone app). I need a way to identify the handset from server side. I was thinking I could write a secret (a cryptographic string of some sort) in persistent storage on the device the first time the app is run, and use this to identify the handset next time it speaks to the back end server. Is this how to do it? Is there a better way?

Clarification: The question should have said, I want to identify the user of the app. I'm not interested in tracking the actual device.

Jepper
  • 1,092
  • 3
  • 11
  • 24
  • 1
    ANDROID_ID. Blog specifically about this subject. http://android-developers.blogspot.in/2011/03/identifying-app-installations.html – Gautham Sep 14 '12 at 05:26
  • Quote from link "To track installations, you could for example use a UUID as an identifier, and simply create a new one the first time an app runs after installation. " Thanks @Gogu this was indeed useful. – Jepper Sep 14 '12 at 07:25
  • Ok I did not read your question properly. UUID is more suitable than ANDROID_ID in your case. If you are using ACRA for crash reporting, acra has an Installation.id you can use for your purpose. – Gautham Sep 14 '12 at 10:47

1 Answers1

0

As much I understood your question, you wish to identify from which device request is coming, not the build or firmware of the phone. In this case you could identify them from their IMEI number, with following code -

TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.getDeviceId();

Add the following permission into your Manifest file :

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
Darpan
  • 5,623
  • 3
  • 48
  • 80
  • Yes, you're correct. The reason for this is that I don't want the user to sign on with user/pass credentials. It should "just work" but we still need to uniquely identify the user at the back end. – Jepper Sep 14 '12 at 06:57
  • I think Apple store will reject apps polling for IMEI. I would personally find it intrusive if an app was to dig this deep. The question was, does the proposed solution work, and can it be done better? – Jepper Sep 14 '12 at 07:11