I´m playing around with the FirebaseUI-Android and have a question about what ID to use when uniquely identify users. The FirebaseUI managed the authentication right and return the IdpResponse object. This can be e.g. Facebook, Twitter, Phone and more.. This is grate thanks everyone behind this.
Because the FirebaseUser.getUid() can change when user delete/recreate his account therefore i don't want to link my users data with the FirebaseUser.getUid() token.
In the future if I decide to let user wipe there account the uid will change when user come back and all user history for that user in my system is not accessible anymore right. Also in the future if I migrate my system to someplace the uid will not be that handy to have around right?
Now I created this wrapper(code below) to create a unique ID extrapolated from the data inside the IdpResponse. Dunno really but I figure doing it this way there will never be a "id" collision unless there´s a Google2.0 e.g. Twitter2.0 :) right. And at the same time it´s easier to debunk bugs in the system because id´s are not UUID.
Is this a recommended way to handle the user id problem. I really need some feedback and pitfalls warnings about this.
@Override
public String getUserId() {
String userId;
FirebaseUser user = getInstance().getCurrentUser();
if (user.getEmail() != null)
// User sign in with E-Mail
userId = user.getEmail().replace(".", ",");
else if (user.getPhoneNumber() != null){
// User sign in with Phone
userId = user.getPhoneNumber();
}else
// User sign in with Twitter or Facebook
userId = user.getUid();
return userId;
}
What bother me most with this is the Twitter or Facebook since I still have to use the FirebaseUser.getUid(). Is the IdpResponse.getIdpToken() better to us?