facebook-instant-games

FBInstant.updateAsync() resolves successfully but do nothing


I'm trying to call FBInstant.updateAsync() at chat context (with id=THREAD). It resolves successfully, but don't post any messages at chat. Does anybody know why is that happens?

Issue was fixed, working code:

FBInstant.updateAsync({
    action: 'CUSTOM',
    //cta: 'Join The Fight',
    image: 'data:image/jpeg;base64,/...',
    text: 'X just invaded Y\'s village!',
    template: 'test_template',
    data: { myReplayData: '...' },
    strategy: 'IMMEDIATE',
    notification: 'NO_PUSH',
}).then(
    () =>{
        console.log('updateAsync() success!' + JSON.stringify(data));
        FBInstant.quit();
    },
    error => {
        console.error('updateAsync() ERROR! ' + JSON.stringify(error));
    }
);

Here is my fbapp-config.json:

{
  "instant_games": {
    "platform_version": "RICH_GAMEPLAY",

    "custom_update_templates": {
      "test_template": {
        "example": "X just invaded Y's village!"
      }
    }
  }
}

Solution

  • Firstly, I am under the impression you should have a base64 encoded image in the image field, not a base64 encoded URL. You can try using https://www.base64-image.de to encode an image with base64. Maybe your update is actually failing due to that!

    Secondly, for the getEntryPointData() to return data, you must have entered the game via a custom update, and it will return the data that was set with updateAsync. When an user enters the game via the update, they won't enter the .then(), as what your code seems to try and do.

    If changing the image to an encoded image doesn't fix the updateAsync, you could try debugging via the chrome inspector and setting the "pause on uncaught exceptions" toggle, and see if a crash occurs during the updateAsync