Reputation: 2698
I'm designing an Android mobile application. The application uses a credit system. The user can buy credits through the Google in app billing services. Moreover, when the user installs the application, it gets some free credits.
The user credits are stored in a web server. When the user downloads the application, a UUID is created and stored in the app & server.
I need somehow to detect when the user uninstalls the app, and reinstalls it, in order to receive the starting free credits (reinstall will create a new UUID, so it will be like a new user).
I've been looking for a phone or user identifier, but I've read that this is not a very nice idea (http://android-developers.blogspot.com.es/2011/03/identifying-app-installations.html Is there a unique Android device ID? or How to find serial number of Android device?). Moreover, this can be hacked easy in order to use a not owned account.
Is somehow to solve this problem? Maybe using the in app billing? I'm opened to any solution.
Thanks
Upvotes: 1
Views: 311
Reputation: 1421
Why not to use IMEI. It's easy to get. It's hard to change and in many countries it'is illegal (to prevent phone robbery). We use it for many purposes. And you would only need one extra permission READ_PHONE_STATE. (Most user do not complain)
In very few devices it may return NULL, in that case you should be prepared and test another unique identifiers like the Serial No. The Mac Address. Android ID or the UUID. As you said this last identifiers are more easily hacked but since there are very few devices is less likely you have hacking problems.
The solution is more about design. By example in video games if you re install the game to get free virtual cash, you'll also be deleting your save so you'll start from zero ending up with the same amount of cash. Since there is not transfer of cash between players this cannot be exploited.
If you are providing a web service. You can also check for IP in every request. And therefore keep a track of the amount a request and the total credits. This along with IMEI. Finally if you belive is really important, you could request a credit card (with no charge) just to prevent multiple accounts of the same user. For most services is not necessary because you will have less users and it may end up being worse.
Upvotes: 0
Reputation: 39577
As you are totally right (identifying devices is useless) I would use the Google user account to achieve people identification:
http://developer.android.com/training/id-auth/identify.html
AccountManager accountManager = AccountManager.get(getApplicationContext());
Account[] accounts = accountManager.getAccountsByType("com.google");
for (Account a: accounts) {
if (a.name.contains("@gmail.com")) {
return a.name;
}
}
This might be tricky but will allow you to identify reisntall from the same Googkle Play account that downloaded the app.
Upvotes: 2