Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase - Unique ID for every user

I am building a firebase based android application which involves multiple user who authenticate and login to app. I want to provide a Unique to each users who authenticate&login and which will not be changed even if user reinstall the application so that I can use and rely on that key to make a separate json branch for that specific user in database based on that id.

I have searched the docs I found user.getUid() and user.getToken(). I am confused about these two which one will help me considering my situation.

like image 769
GeekWithGlasses Avatar asked May 03 '17 09:05

GeekWithGlasses


1 Answers

Definitely use user.getUid(). It's a standard Firebase practice to use this UID to create a dedicated JSON branch for that user (on the database), just like you described.

This UID will remain the same even if the user deletes your app. As soon as he logins back again, he will be assigned this exact same UID.

like image 81
Paulo Mattos Avatar answered Nov 08 '22 02:11

Paulo Mattos