question

wayneprim90 avatar image
wayneprim90 asked

Link With Facebook Question/Problem,Unity LoginWithDevice then Linking With Facebook Question

I am working on starting the user authentication flow for my mobile ios unity game and am running into some troubles. Basically I would like to be able to just log the user in using their device ID and prompting them later to link their account to their facebook to save their progress. But what happens after they link their account? Because my main connecting scene has them logged in using their device id... How do you switch to using login with facebook now that the account is linked to their facebook?

My connection screen basically goes like this:

1. PlayFab -> LoginWithIOSDevice() { Create Account = true } //This creates a seamless login experience...

2. Take them to lobby scene.

But say after they go to lobby screen they link their account with facebook. Next time they open the app they will go through the same LoginWithIOSDevice...

I am guessing a fix would be before the LoginWithIOSDevice to check if the user is logged into facebook. If not, go through with IOS Device Login. If they are logged into facebook just call the LoginWIthFacebook() method:

1. Facebook SDK -> Check if user has access token.

2. If yes, PlayFab -> LoginWithFacebook()

3. If no, PlayFab -> LoginWithIOSDevice() { Create Account = true }

But the problem with this approach is say the user, after linking to facebook and closing the app, logs out of facebook on their phone... The next time the user opens the app, it would check if the user is logged into facebook and if not they would just get authenticated using device id even though their account is linked in with facebook! How do you get around this?

,

I am working on starting the user authentication flow for my mobile ios unity game and am running into some troubles. Basically I would like to be able to just log the user in using their device ID and prompting them later to link their account to their facebook to save their progress. But what happens after they link their account? Because my main connecting scene has them logged in using their device id... How do you switch to using login with facebook now that the account is linked to their facebook?

My connection screen basically goes like this:

1. PlayFab -> LoginWithIOSDevice() { Create Account = true } //This creates a seamless login experience...

2. Take them to lobby scene.

But say after they go to lobby screen they link their account with facebook. Next time they open the app they will go through the same LoginWithIOSDevice...

I am guessing a fix would be before the LoginWithIOSDevice to check if the user is logged into facebook. If not, go through with IOS Device Login. If they are logged into facebook just call the LoginWIthFacebook() method:

1. Facebook SDK -> Check if user has access token.

2. If yes, PlayFab -> LoginWithFacebook()

3. If no, PlayFab -> LoginWithIOSDevice() { Create Account = true }

But the problem with this approach is say the user, after linking to facebook and closing the app, logs out of facebook on their phone... The next time the user opens the app, it would check if the user is logged into facebook and if not they would just get authenticated using device id even though their account is linked in with facebook! How do you get around this?

Account ManagementAuthentication
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

First, I'd recommend reading our tutorials on login, starting with this one: https://api.playfab.com/docs/tutorials/landing-players/best-login.

Now, as to how to manage your login flow, it really just depends what your requirements are. You could, for example, always just login with Device ID, and use the linked Facebook account as the way for players to get their account on a new device (and link it to that account) by offering the "already have a Facebook-linked account? Click here" type of option.

If you need to use the Facebook friends list however, we will need a current token from the service for the player, in which case you will need to log in with Facebook. But you can do that after you've already logged the player in with the Device ID.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

wayneprim90 avatar image wayneprim90 commented ·

Okay, thanks for the response!

As for the device id... if the player then sells that phone wont that buyer of the phone be able to access their account??

0 Likes 0 ·
brendan avatar image brendan wayneprim90 commented ·

For iOS devices, that's a non-issue, as the Device ID is generated for the user when the first title from the developer is installed. So unless you're giving the other person your phone, with your SIM card and all your apps, that can't happen. For Android, a factory reset is supposed to change the Device ID, but it's worth reminding users that they should unlink their device from the game if they get rid of their device.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.