Best practice to handle Firebase user names when using Gamecenter and Playstore authentication

190 views
Skip to first unread message

habitoti

unread,
Apr 1, 2020, 11:47:04 AM4/1/20
to Firebase Google Group
I am planning to support iOS in addition to Android for a Unity app with a Firebase backend. I am using Playstore authentication for Android, and want to use Game Center auth. accordingly for iOS. As there is a high likelihood of displaynames redundancies of users from both worlds, I wonder if there is a best practice to handle that or some experience from others who already dealt with that? Like annotate display names with "-i" and "-a" ("gambler01-i" vs. "gambler01-a") or something similar.

Patrick Martin

unread,
Apr 15, 2020, 12:38:07 PM4/15/20
to Firebase Google Group
I think I ran into you on Twitter didn't I (@pux0r3)?

It's definitely a good strategy. You'll probably want to give each userid generated via Firebase Authentication a "display name" field in your database with this name. Just looking around at different games services I'm on, Battle.net does add a #<random digits> to my username and Stadia has a similar feature for new users.

You'll want to be careful about your database structure to make sure that the process by which you add these annotations is fast and guarantees uniqueness (it would be easy to lock up your entire database if you did some exhaustive search over your entire `users` node to perform this action).

--Patrick

habitoti

unread,
Apr 16, 2020, 1:17:49 PM4/16/20
to Firebase Google Group
Hi Patrick,

yes, that was me ;-)

As said on Twitter, I'll do it as you proposed also here now. Honestly I would have hoped that this kind of cross-platform harmonisation of user display names would be solved by the Firebase backend already in the course of the initial sign-up procedure and so not only deliver unique user IDs, but also unique display names (hard to imagine any useful use-case of having different physical users showing up with the same name in a cross platform application, be it a game or anything else...). On any single platform this would be prevented on sign-up already (within the platform), so here some extra distinction might be required if an according user exists and signed-up to Firebase already from a different platform.

BTW: is it normal that Gamecenter-authenticated users show up with a dash only under their user id in the Firebase console authentication view (with Firebase Auth module correctly reporting a display name within the authenticating app)?


Graham Dickinson

unread,
Apr 16, 2020, 1:56:25 PM4/16/20
to Firebase Google Group
Not sure I agree that Firebase should enforce this as a database. In the real world many people have the same name and applications such as LinkedIn, Facebook, etc. recognise and support that. It is surely the responsibility of the application to handle people who want the same name?

habitoti

unread,
Apr 16, 2020, 3:49:47 PM4/16/20
to Firebase Google Group
But in your sample you have the same person on different backends. Just fine to identify to other humans with the same displayname then (I do that, too). But here you have different people potentially happen to have the same user display name when authenticating via PlayGames and Gamecenter. Just check out how many „killer<nn>“ user you have on either. If on the other hand I happen to be the same player, owning say an Android phone and iPad, I might try to use the same displayname („killer01“), but I am actually two different users with different UIDs on the backend after sig-up, so I could play Multiplayer against myself then ;-). No way to merge them into one.

I can‘t think of a useful scenario of having same displayname and different UIDs for the same application.
Reply all
Reply to author
Forward
0 new messages