开发者

What's the best way to uniquely identify Android users to a server?

开发者 https://www.devze.com 2023-01-20 19:43 出处:网络
How should I go about identifying an android user to a server. Should I get the IMSI number and some salting algorithm?

How should I go about identifying an android user to a server. Should I get the IMSI number and some salting algorithm? Considering androids space and performance limitations is there a library that isn'开发者_如何学运维t too heavy that I can use to do the calculation?


I think you cannot identify a user without any kind of account. Everything else is not reliable or only a device identification. Why don't you provide an own registration service for your server, so you can give an unique id to every user.

Another option might be the Google account which is bound to the device? Or will this cut you target audience for your up? But if you're building an app which extends some sort of Google tool, app or whatever then user will already have a Google account so your app could also use it to identify the user.


As stated by developer.android:

Applications typically try to remember the user using one of three techniques:

  1. Ask the user to type in a username
  2. Retrieve a unique device ID to remember the device
  3. Retrieve a built-in account from AccountManager

Option (1) is problematic. First, asking the user to type something before entering your app will automatically make your app less appealing. Second, there's no guarantee that the username chosen will be unique.

Option (2) is less onerous for the user, but it's tricky to get right. More importantly, it only allows you to remember the user on one device. Imagine the frustration of someone who upgrades to a shiny new device, only to find that your app no longer remembers them.

Option (3) is the preferred technique. Account Manager allows you to get information about the accounts that are stored on the user's device. As we'll see in this lesson, using Account Manager lets you remember your user, no matter how many devices the user may own, by adding just a couple of extra taps to your UI.


in a few months many more users will have android phones and android tablets so if you want to track a user over multiple devices it's best to use OAuth I think.


To identify the user I should think using the google account is the best option, see the answer at Generating Device-Specific Serial Number

If you just wish to identify an instance of your application, then why not let the server distribute ID:s?

When your app launches, get SharedPreferences and check if "myid" has a value, if not, then request an ID from the server, which you store as "myid" in SharedPreferences. This id will survive app updates (but not uninstall/reinstall).

On the server side, store all registered ID's, and make sure your server distributes unique id's. This way, nasty people hacking your server can't use the ID's to identify your users ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消