lolerji Posted March 6, 2020 Share Posted March 6, 2020 Hello everyone. Past few days, I have been trying to add a challenge mode to my game which involves the challenger selecting one of their friends from the popup FBInstant.chooseAsync() method opens. After this, chooseAsync() is supposed to create a new context with that facebook account, and then the game starts the challenge mode which on completion would send a notification via the chat to the challenged account that their friend challenges them. When they open the game from that notification, they start playing in the challenge mode, then when they finish, scores are compared and winner is announced on chat again. The challenge mode, opening the game from the notification and/or sending the notification functions are currently working fine. The problem is, FBInstant.chooseAsync() sometimes creates an invalid context. What actually happens is, chooseAsync promise is resolved without any errors, then the game makes a call to the context to get the players in the context and select the player that is not the current player (the opponent), however it cannot, because the context either only has the current player in the context or doesn't have any players in the context at all. FBInstant.context.getPlayersAsync() when resolved returns a player array with either 1 or 0 players in this case. Long story short, selecting certain facebook accounts from the popup of FBInstant.chooseAsync() creates an invalid context which doesn't have the selected opponent in it. Checking some games on Facebook Instant I came across the same issue as well, however they handle it gracefully. My question is: Why does this issue occur, and is there a solution on my end that I can implement? Is there an elegant way of handling this if there are no solutions, since the chooseAsync promise is not rejected in case it creates invalid context (doesn't fall to .catch())? Quote Link to comment Share on other sites More sharing options...
b10b Posted March 7, 2020 Share Posted March 7, 2020 To nod at what you already discovered ... a Context is a mysterious thing (likely subject to ever changing compliances around personal settings, permissions, territories, and privacy?). The Promises returned by FB IG SDK are another layer of mystery, often yielding more false-positives and false-negatives than true anythings. One solution is to check the contents of the response, avoiding expectations as to what it may be (or pondering why it isn't). And be prepared for it to change. Quote Link to comment Share on other sites More sharing options...
Noel Posted March 9, 2020 Share Posted March 9, 2020 My guess here is that it happens when you pick a person that hasn't play the game yet (and/or didn't play the game in the last 90 days). Could you test that hypothesis? Quote Link to comment Share on other sites More sharing options...
jawnwee Posted March 25, 2020 Share Posted March 25, 2020 @Noel I have the same issue as op. When I call chooseAsync() and select a user from the dialog, the recipient does not receive the game invite. Quote Link to comment Share on other sites More sharing options...
Noel Posted March 31, 2020 Share Posted March 31, 2020 @jawnwee chooseAsync() is not an invitation system, it will just create a context for you with that one person to play with. Then you will need to read this: https://developers.facebook.com/docs/games/instant-games/guides/game-update Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.