2

我是即时游戏的新手。请告诉我如何使用

FBInstant.updateAsync({
    action: 'CUSTOM',
    cta: 'Join The Fight',
    image: base,
    template: 'play_turn',
    text: 'Play your turn now',
    data: {
        myReplayData: '...',
        id: contextId
    },
    strategy: 'IMMEDIATE',
    notification: 'NO_PUSH',
}).then(
    () => {
        console.log('updateAsync() success!' + JSON.stringify(data));
        FBInstant.quit();
    },
    error => {
        console.error('updateAsync() ERROR! ' + JSON.stringify(error));
    }
);
}

我也设置了我的 fb 配置文件。

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

"custom_update_templates": {
  "play_turn": {
    "example": "Yolo just invaded village!"
      }
    }
  }
}

如何获取用户的 psid,以及如何向用户发送消息以重新参与。

4

1 回答 1

0

自定义更新

从广义上讲,自定义更新应该是游戏会话的输出。例如,在 Words With Friends 中,每次播放单词时都会发送自定义更新。自定义更新出现在您正在玩游戏的 Messenger 对话中,也可能在 Facebook 通知中用于自动重新吸引玩家(开发者无法控制)。

您已经提供的代码应该足以发送自定义更新,但您必须为参数提供有效的 base 64 编码图像image,否则调用将失败。请注意,要成功发送自定义更新,您的游戏必须在 Instant Games 播放器中播放(在 Messenger.com、Facebook.com 上或通过 Facebook 移动应用程序之一)。Instant Games SDK 不能在 Facebook 之外运行。

Words With Friends 的自定义更新

机器人(重新参与)

您不需要 PSID 来发送自定义更新。您需要 PSID 通过您的 Messenger 机器人(如果有的话)向玩家发送消息。您可以在此处开始使用 Messenger 机器人:https ://developers.facebook.com/docs/messenger-platform/

对于玩您的游戏的所有用户,您的 Messenger 机器人应该会收到一个game_play包含其 PSID 的 webhook。

于 2018-11-16T21:16:24.703 回答