0

I have an issue, that 5% of my users are registering to the server multiple times. This can only happen with a clean, new installation, because I perform a simple registration at the start: (pseudocode):

if(!SharedPrefs.contains(accessToken))
{
    registerToServer(response -> {
        SharedPrefs.save(response.accessToken);
        SharedPrefs.save(); // commit, whatever
    }
}

Then, I store his device UUID on the server.

As you can see, a user cannot be registered twice on the same device. The only way he can, is by reinstalling the app, because the SharedPrefs would be wiped.

But...

There are people who are registering twice, 3 times or even more. I can see that by filtering by the deviceID in my database and I have multiple user records with the same deviceID.

To solve that, I need to make sure, it is not some kind of bot (like Google Play pre-launch report devices).

The question

Is there any way, to get some kind of Unique Installation identifier, that will be identical only to the same Google Play installation event?

You'll probably say, that I could check that with SharedPrefs themselves, store some kind of bool "firstInstall" and it would be wiped with a new install. But I can't because I have assumptions that SharedPrefs are getting wiped somehow on app launch on these devices.

This happens mainly on some LG's, Samsung J5, "vivo vivo", Huaweis.

Community
  • 1
  • 1
Jacob
  • 351
  • 2
  • 9
  • Just make deviceID as primary key in the database. – sushildlh Mar 15 '19 at 09:37
  • if you go to the app by settings, you can delete your shared prefs by deleting app data – Ivan Mar 15 '19 at 09:38
  • @SushilKumar DeviceID as a primary key is not a solution. It will just hide the problem. – Jacob Mar 15 '19 at 09:41
  • @Ivan I know I can. But what's the probablility that 5% of the users are doing that? And why?! – Jacob Mar 15 '19 at 09:42
  • why don't you use email login (google login) or phone number login (account kit by facebook)? – Rishabh Sagar Mar 15 '19 at 09:44
  • @Spectre why primary key or unique key isn't option. Will you explain more please. Duplication resolve using these fields. – sushildlh Mar 15 '19 at 09:45
  • you can't do much from the client side.you have to check database. if uuid exist don't create a new row and just login the user – codegames Mar 15 '19 at 09:47
  • Primary key is an option, I can easily to that, but the problem is on the client side. Why are there registering multiple times? Are the SharedPrefs wiped, or the app is reinstalled? That's the problem. – Jacob Mar 15 '19 at 09:53
  • you can save some information in a file to restore that data after reinstalling the app. but still user can remove that file to. maybe you can hide it some where – codegames Mar 15 '19 at 09:55
  • whenever you reinstall or update app, Your SharedPrefs wipe out sometimes or some devices. Form this [link](https://stackoverflow.com/a/12637972/5305430). So its better to validate user from your server database using primary key or unique key. – sushildlh Mar 15 '19 at 09:59

1 Answers1

-1

Your assumption that SharedPrefs only get cleared on uninstallation is wrong. For any app, at any time, a user can do "clear apps data". And there exist many (not very good) Phone cleaner tools that offer to do this for the user.

The official android guidelines for unique identifiers are here.

The recommendation depends what purpose the identifier is for. It sounds like you might be using it for user profiling, ao an Advertising id might be appropriate.

Nick Fortescue
  • 13,530
  • 1
  • 31
  • 37