1

I am building a mobile multiplayer game using unity and firebase. I wanted to reduce my real-time database bills.

My app is very social driven:

  • Friends

  • Friend Requests

  • Gifts

  • Game Invites

  • etc..

As you know, the firebase way of identifying different users is UID: a 28 characters long alpha-numeric string.

And naturally each tree looks something like this:

friends:
  user-uid(28 chars):
    friend1-uid(28 chars): true,
    friend2-uid(28 chars): true,
    friend3-uid(28 chars): true,
    ....
    ..

friend_requests:
  user-uid(28 chars):
    friend1-uid(28 chars): true,
    friend2-uid(28 chars): true,
    friend3-uid(28 chars): true,
    ....
    ..

users:
  user1-uid(28 chars):
    exp: 28,
    username: "example_username",
    name: "example_name",
    skin: 2,
    ....
    ..

To load my friends data on app launch I have to download 28 bytes (to get uid of all my friends) and than search the "users" tree to get their info (again 28 bytes in the key of the snapshot)

My questions:

1) Why is the UID generated is a string 28 characters long?

2) Why can't the UID be alpha-numeric [A-Za-z0-9] that is incremented with each new auth (Creates 56,800,235,584 unique options with just 6 characters [Without even counting the options that are less than 6 characters]).

3) I suppose my question is not going to change the way firebase is generating UID's, so I'd like to know if there are any solid solutions (not messy work-arounds) for these 28 char strings I am stuck with.

Thank you a lot! :)

Tal Rumer
  • 11
  • 2
  • Instead of indexing by UID, you can just index by username, if you ensure they are unique. And if I recall right, a same user logged with external accounts (Facebook, Twitter, ...) will have different UIDs for each. If you want to allow multiple connections path for the same user, better not identify an user with them. – Kamalen Aug 10 '18 at 12:28
  • @Kamalen Where did you see that a user signing from different external accounts have a different UID? And how could one end up going around that so that the same person also has the same UID? – payne Aug 10 '18 at 15:27
  • @payne That was from a previous experience with Firebase. That makes sense, because you could want to link accounts with differents emails for some reasons, and the DB has no way to know you're the same user. Usually an app allows linking the various accounts to allow login with all. – Kamalen Aug 10 '18 at 15:36
  • @Kamalen What is generally the approach to allow the linkage of multiple accounts to allow login with all? – payne Aug 10 '18 at 15:38

0 Answers0