Sign In Register

How can we help you today?

Start a new topic
Answered

Help with slightly unusual Facebook usage

Due to the way our game is set up, we're letting user's login through our client's user database, which means we can't and wont allow them to login with Facebook. However, we do want them to be able to connect their GameSparks account with Facebook for the sole purpose of finding and adding those of their Facebook-friends who are also playing the game and have connected through Facebook. We are using this approach for friends lists in our game (or a slightly modified version of it), so what we want is to send friend requests to all the user's friends that are also connected to Facebook, using this method. Ideally also automatically accept the friend requests.

So far I seem to have something working that connects to a Facebook account, but there are also some issues in that. What happens if a user logs in on his account in our system then goes to connect with his Facebook account, but then later wants to connect to another Facebook account? Can he switch? I know there's the 'SetSwitchIfPossible' that I can enable, but not really sure if that's the intention of that method. On the other hand, if another person logs in on another account in our system - on the same device - we don't want him to automatically be connected to the first user's Facebook. And what if one user tries to connect with a Facebook account that someone else has already connected to? There are a lot of edge cases here that I don't really know how to solve and would like to get ideas about how to work around.

As said, our system only really wants to use Facebook to find and connect friends. So once a user connects to Facebook, the system should find all his friends that plays the game and connect them with the user. Then from that point on, every time the user logs in, the game should automatically connect with Facebook, check if any new friends has joined and then connect them with the logged in user. Any ideas, inputs or meta code approaches on how to go about this would be much appreciated.

Best Answer
Hi, Sean.

Thanks for your reply. I ended up just going ahead and making an attempt at an implementation, which seems to work now. Basically what I do is to ask the user to login on Facebook, when clicking a 'Connect to Facebook' button in our app. Once they login, I store the access token (and some other information) in the script data of their GameSparks account. At the same time I call the ListGameFriendsRequest in GameSparks to find all the user's friends, who're also playing our game. If there are active Facebook friends, which are not friends with the user in our game, I add each user to the other's friends list, through cloud code. Then every time the user logs in from that point on, I call the FacebookConnectRequest with the stored access token and check for new friends. If the access token has expired, I ask the user to login on Facebook again and then store the new access token. As said, this approach seems to work the way we need it to. Not sure if it's the easiest way to do it, but as long as it works, I'm happy :)

Having checked how other apps handle multiple device logins, it seems it's mostly let up to the users to manage the Facebook accounts on their devices, so we'll just handle it this way to. If a user chooses to log in with a 'wrong' Facebook account, we let them do that.

Regards,
Heino Jørgensen

 


Hey Heino,

Do you have the FB SDK integrated?
I might suggest you skip the gamesparks facebook connect altogether and just request a friends like from FB through their SDK. Then send that list back to the player's GS account and maybe do what you can with those account number in cloud code.

This would cut out a lot of confusion with FB/GS accounts sharing details.

As for the multiple device logins, there isnt much you can do about that from our end. You might see if the FB SDK can clear its auth-token when the app exits. This would mean you'd have to login to FB every time you relaunch the app.

Does this help?
Sean

 

Answer
Hi, Sean.

Thanks for your reply. I ended up just going ahead and making an attempt at an implementation, which seems to work now. Basically what I do is to ask the user to login on Facebook, when clicking a 'Connect to Facebook' button in our app. Once they login, I store the access token (and some other information) in the script data of their GameSparks account. At the same time I call the ListGameFriendsRequest in GameSparks to find all the user's friends, who're also playing our game. If there are active Facebook friends, which are not friends with the user in our game, I add each user to the other's friends list, through cloud code. Then every time the user logs in from that point on, I call the FacebookConnectRequest with the stored access token and check for new friends. If the access token has expired, I ask the user to login on Facebook again and then store the new access token. As said, this approach seems to work the way we need it to. Not sure if it's the easiest way to do it, but as long as it works, I'm happy :)

Having checked how other apps handle multiple device logins, it seems it's mostly let up to the users to manage the Facebook accounts on their devices, so we'll just handle it this way to. If a user chooses to log in with a 'wrong' Facebook account, we let them do that.

Regards,
Heino Jørgensen

 

Login to post a comment