How to remeber users without sign up in android?

224 Views Asked by At

Im working on a project where a user isn´t forced to sign up a account. My plan is that a user could do anything like a user that is registered except for a few exceptions. I implement a like function which saves the users behaviour on a webserver and later when the data is fetched again it recognized if the user liked something or not. My problem is that I have to save this informations also if the user isn´t registered to my application. A User should be free to decide wheter the user likes to sign up or not and isn´t forced to be a registered user. I found three different way that could work!

1. Option

First option would be the accountmanager but I don´t like this option at all cause I have to ask for the contact permission and also ask which account a user want to use.

2. Option

A other option would be if a user starts the app for the very first time the app would call a server which creates a random unique code and send that code to my application to save it as key for the users actions which is saved on a server. But that also doesn´t seems to be a good solution for my problem.

3. Option

The last option would be oauth but for now I don´t know if and how it would be the solution to my problem!

I would be thankful for every answer!

3

There are 3 best solutions below

1
Rahul On BEST ANSWER

I have worked on a comic app that requires saving the user subscribed channels, genre or comics and save the likes/dislikes for the same. User can be subscribed to push notification too.

For this, we used Firebase Authentication (anonymous signup). And to save the user subscription information, we used Firebase Firestore.

And followed the below approach.

  • As soon as the app opens, check if the user has already anonymous SignIn. If it hasn't, signUp silently.
  • Add a listener for user push notification token change. And update it to Firestore by anonymous user-id as key (We did same for storing other information too).

I think this approach would help to solve this problem.

1
Ido Barnea On

You could use firebase auth for that! Usually, you would use it with email & password or google login but it also has an anonymous login feature that should save the user's phone.

1
Oleg On

There are few techniques. It depends on whether you want to recognise a user between installations of app. If you are OK to lose a user on reinstallation you can use Firebase installation ID and link users behaviour with this id. If you want to remember users even between installations you can use unique to each combination of app-signing key, user, and device Secure.ANDROID_ID(more info about ids). But still the best way is implementing your own signing in or using of AccountManager.