Skip to content Skip to sidebar Skip to footer

When To Use Firebaseauth User Uid And When To Use An E-mail As Identifier

With This Question in mined here´s a follow up question. Correct me on my assumptions please my learning curve is aggressive :). If making lets say a chat app having Firebase

Solution 1:

It's not a bad idea to use getCurrentUser().getUid() but a better idea is to use as an identifier the email address. I'm saying this because in the case in which the user is is deleting the account and than returns, the uid will be for sure different. Because Firebase does not allow the dot symbol . in the key, the email address must be encoded like this:

name@email.com -> name@email,com

As you probably see, i have changed the . with ,. To do this, i recomand you using this methods:

staticStringencodeUserEmail(String userEmail) {
    return userEmail.replace(".", ",");
}

staticStringdecodeUserEmail(String userEmail) {
    return userEmail.replace(",", ".");
}

Hope it helps.

Post a Comment for "When To Use Firebaseauth User Uid And When To Use An E-mail As Identifier"