Jump to content

Strange issue with FBInstant.chooseAsync()


lolerji
 Share

Recommended Posts

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())?
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 3 weeks later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...