Unique Identifiers: There’s a better way with Instance ID
Pro-tip by +Joanna Smith
There are plenty of reasons you’d want to track your app on a device. But unless you’re a wireless carrier, I’m willing to bet that what you really want is to track installations
. Because if you’re focusing on the device, you’re doing it wrong. After all, if I factory-reset my tablet and give it to my sister as a hand-me-down, and then she also installs your app, that is a different user story
One example of being device-focused is using MAC addresses, since they are globally unique and persist across factory resets. But they clearly aren’t great for user identification (see my super-nice sister gift above) and now you’ll find that on Android 6.0, there is no programmatic access to either Wi-Fi or Bluetooth addresses.
And now, I’d like to direct your attention to the Instance ID
), which provides a unique identifier for each instance of your app, enabling you to identify and track your app instances around the world. Which solves the problem of all those super-nice sisters out there.
But the Instance ID API can also generate security tokens
that can authorize third parties to access server-side resources, like sending messages with Google Cloud Messaging. With the help of the Instance ID service (https://goo.gl/LyLlYp
), it can verify the authenticity of apps
distributed through Google Play, so that your server can trust this Android client. And the Instance ID service can even tell you if the app device is active
, which will help your app make decisions about whether to re-engage with users. If the device hasn’t been used in a month, maybe you don’t want to bother with that push message.
If you prefer to manage your unique identifiers in your own way, might I recommend a GUID (globally unique ID)? They are simple to make, if you use the UUID
Android API (http://goo.gl/jeEaWy
) and call randomUUID()
. You’ll need to store it yourself, in internal storage, to protect the GUID across applications.
One of these two options will probably solve the majority of your needs, but there are a few special cases. So I have more recommendations for you!
+For user profiling and ads, use Advertising ID (https://goo.gl/Z1pmhY
+For content protection, check out the Widevine/DRM Plugin (https://goo.gl/cvT0W2
+For abuse prevention, go with the SafetyNet API (https://goo.gl/SxxRyG
+And if you are actually trying to do telephony, then do not let me get in the way of your IMEI. You do you.#BuildBetterApps