Android Firebase - save data without authentication

I am making an example note taking application with Firebase where users can log in and create simple text notes. My Firebase data structure is as follows:

"Project-dir":{ "Notes":{ "UserID":{ "NoteKey":{ "title":"This is note title", "content":"This is the note content", "unixTime":123456789 }, "NoteKey":{ "title":"This is note title", "content":"This is the note content", "unixTime":123456789 }, } } } 

It works great when a user logs in. However, I want to add the "Continue without logging in" functionality. I created a unique user ID using push () to use instead of the URI and storing it in sharedprefs. However, how can I transfer all of these notes to a user identifier (UID) when he decides to register later?

+5
source share
1 answer

In this particular use case, you want to use the Firebase Authentication anonymous authentication provider .

It is essentially the same as it is now (it generates a random identifier for the current user / device). The difference is that you can update the anonymous authentication user to the authenticated user later by linking your Facebook / Google / Github / Email account.

+7
source

Source: https://habr.com/ru/post/1261666/


All Articles