Facebook Instant Games API 方法 canSubscribeBotAsync() 在测试时总是 returns false

Facebook Instant Games API method canSubscribeBotAsync() always returns false while testing

我正在测试一个即时游戏应用程序,我最终希望我的机器人收集 messaging_game_plays 事件以在游戏会话结束时记录用户数据。为了允许 messaging_game_plays 被发送,我已经按照 to canSubscribeBotAsync(), and subscribeBotAsync() from the Facebook Instant Games API v6.2. Following the API reference as a guide, I've built these canSubscribeBotAsync and subscribeBotAsync methods into the game's startup sequence. I also have my fbapp-config.json 的指示设置了正确的

{
    "instant_games": {
        "bot": {
            "subscription_type": "OPT_IN_DEV"
        },
        ...
    }
}

我面临的问题是,当我测试应用程序时,canSubscribeBotAsync() 总是 return 为假,因此当它 return 为真时,我无法测试该行为。当 return 为假时,canSubscribeBotAsync() 似乎没有 return 任何其他信息,所以我不确定是什么导致它 return 这样。

我目前正在通过构建游戏并将其上传到 Facebook 应用程序来测试此问题,然后将其移至测试阶段。然后我一直在用我的 facebook 帐户玩这个游戏。

我的问题是: 有什么方法可以知道为什么 canSubscribtBotAsync() return 是假的吗?或者我的 Facebook 应用程序或个人 Facebook 个人资料中是否存在可能导致 canSubscribeBotAsync() 始终 return false 的设置?

我确实在该方法的文档中注意到任何给定的玩家只会被提示一次。我从未见过选择加入提示,但是否有可能你已经看到它的标志被触发并且因此 returning false?

我曾让其他人用他们自己的帐户尝试过同样的行为。我现在正在测试更多的可能性,但我想我现在会 post 这个,以防任何人立刻觉得不对劲。我不期望找到任何革命性的东西,但如果我发现任何其他东西,我会更新这个问题。

[edit] 尝试使用另一个新的 facebook 帐户,并且第一次能够看到游戏日志 运行。它向用户发送了一条消息,说该应用程序想要访问 public 配置文件数据,并且在用户点击数据提示上的接受之前 canSubscribeBotAsync() returned false。单击 "OK" 后,应用程序恢复正常。

加载顺序: 这是我 运行 // rest of game setup logic 用于 Phaser 3 游戏设置逻辑的代码。

window.onload = () => {

    console.log('FB Instant Games SDK Version: ' + FBInstant.getSDKVersion());

    FBInstant.initializeAsync().then((value: boolean) => {

        FBInstant.player.canSubscribeBotAsync().then((can_subscribe: boolean) => {
            console.log((can_subscribe ? 'can' : 'cannot') + ' subscribe player to bot');
            if (can_subscribe) {
                FBInstant.player.subscribeBotAsync().then(function () {
                    console.log('subscribed player to bot');
                }).catch(function (e: any) {
                    console.log('didn\'t subscribe player to bot. error: ' + e.message);
                })
            }
        }).catch(function (e: any) {
            console.log('couln\'t check if player can be subscribed. error: ' + e.message);
        });


        // rest of game setup logic

    });
};

在应用程序的其余输出中,我总是得到以下输出:

FB Instant Games SDK Version: 6.2
cannot subscribe player to bot     <--(canSubscribeBotAsync returning false)

我尝试了多种不同的启动顺序安排,但我可能没有正确设置?

This question 看起来有一个非常相似的问题,但是线程没有解决方案就结束了。

如果有人有任何想法或任何文档可以为我指明正确的方向,我们将不胜感激!我自己浏览了相当多的内容,但我可能在此过程中遗漏了一些东西。

这已经在上面的评论中了,但我会把它放在这里,因为它是我问题的解决方案!

原来我在startGameAsync之前打电话给canSubscribeBotAsync。这是最终为我工作的电话顺序。这成功提示用户选择加入机器人消息传递:

window.onload = () => {

    FBInstant.initializeAsync().then((value: boolean) => {

        FBInstant.startGameAsync().then(function () {

            FBInstant.player.canSubscribeBotAsync().then((can_subscribe: boolean) => {
                if (can_subscribe) {
                    FBInstant.player.subscribeBotAsync().then(function () {

                        // start game here

                    }).catch(function (e: any) {

                        // and here regardless

                    })
                }
            }).catch(function (e: any) {

                // start game here too, launch the game!

            });

            // or start game here if the game should load underneath the popup
            // this ended up not having good flow so we started the game above

        });

    });
};