user14028806
user14028806

Reputation:

How are handle multiple authentication provider (firebase)

I am developing my first mobile game and implementing firebase authentication (with Firestore) in it.

I have some difficulties understanding how are managed multiple auth provider (in an architectural way)

Let's say a user plays my games on both his iPhone and his iPad. Of course, he wants to retrieve his progress in the game on both devices. In my game you have the following possibilities to authenticate:

How may I handle a user that will auth with all of these providers. If the user first auth anonymously on both devices it will create two different users. Now if on the iPhone he uses GameCenter auth and wants to retrieve his account on his iPad how do I handle this. Do I have to link the anonymous iPhone account with GameCenter (using LinkWithCredential for example) and then when he will connect on his iPad with GameCenter the data of iPhone will be retrieved? Or do I have to create another different user? and what if on top of that you add a Facebook connection (and for example the user wants to retrieve his data on the Android device because of Facebook auth).

I am a little confused about that and the firebase don't really help me (maybe I misunderstand it).

Upvotes: 1

Views: 108

Answers (1)

Alex Mamo
Alex Mamo

Reputation: 138804

If the user first auth anonymously on both devices it will create two different users.

There will be two different anonymous accounts on each device.

Now if on the iPhone he uses GameCenter auth and wants to retrieve his account on his iPad how do I handle this? Do I have to link the anonymous iPhone account with GameCenter (using LinkWithCredential for example)?

Yes, you can do that. But what does it mean? It means that you convert the anonymous account from the iPhone into a real "GameCenter" account, meaning that will be able to continue to work with the same data in future sessions.

And then when he will connect on his iPad with GameCenter the data of the iPhone will be retrieved?

Yes, but only if the GameCenter account used on the iPad is the same as the one that is used on iPhone. But remember, if you try to convert the anonymous account from the iPad into a GameCenter account using the same credentials, you'll get an error message saying that such an account already exists.

Or do I have to create another different user?

There is no need to create another user, you can use the same credentials on each device.

and what if on top of that you add a Facebook connection (and for example the user wants to retrieve his data on the Android device because of Facebook auth).

GameCenter and Facebook are two different providers. Again, if you try to use another provider with the same credentials, you'll get the same error, as the account is already there.

Upvotes: 0

Related Questions