0

I want to give unique usernames to my users from the list of usernames that I have created. But I am not getting the logic of what should be done. I have tried uploading that as a JSON file in the Firebase realtime database but as every name is unique how to call it so that it will be assigned to the user

K.Dᴀᴠɪs
  • 9,945
  • 11
  • 33
  • 43

1 Answers1

0

There is no concept of assigning a unique name to a user anywhere in Firebase, so anything you do will be specific to our app and use-case.

But a common approach would be to associate the UID of the Firebase Authentication user with the user name they selected. So:

usernames: {
  "Sahil": "uidOfSahil",
  "puf": "uidOfFrank"
}

You could have the unclaimed names in the same list, but have a marker value instead of the UID. For example if your marker value is false:

usernames: {
  "Abe": false,
  "James": false,
  "Sahil": "uidOfSahil",
  "Tony": false,
  "puf": "uidOfFrank"
}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807