【问题标题】:Facebook Instant Games stuck at 0% loadingFacebook Instant Games 卡在 0% 加载
【发布时间】:2021-01-09 01:36:03
【问题描述】:

我有一个超级简单的 HTML5 游戏,我正在尝试在 facebook 嵌入式播放器中进行测试,但游戏总是卡在 0% 的加载状态,并且它没有记录我一开始的“测试”这个词,这意味着它甚至没有初始化。这是为什么呢?

https://www.facebook.com/embed/instantgames/YOUR_GAME_ID/player?game_url=https://localhost:8080

我已将 GAME_ID 替换为我的

index.html

<script>

      FBInstant.initializeAsync().then(function() {
            console.log("test");
            var progress = 0;
            var interval = setInterval(function () {

                progress+=3;
                FBInstant.setLoadingProgress(progress);

            } , 100);

      FBInstant.startGameAsync()
          .then(function() {
          // Retrieving context and player information can only be done
          // once startGameAsync() resolves

          var playerName = FBInstant.player.getName();
          var playerPic = FBInstant.player.getPhoto();
          var playerId = FBInstant.player.getID();

          // Once startGameAsync() resolves it also means the loading view has 
          // been removed and the user can see the game viewport

          game.start();
      });
    });
</script>

【问题讨论】:

  • 任何帮助将不胜感激

标签: javascript html facebook facebook-instant-games


【解决方案1】:

Facebook Instant game 将在 HTTPS 上运行,您的 chrome 浏览器选项卡应在 localhost URL 下方打开

https://localhost:8080

然后在下一个选项卡中,您应该运行以下 URL,现在它可以正常工作了。

https://www.facebook.com/embed/instantgames/YOUR_GAME_ID/player?game_url=https://localhost:8080

【讨论】:

  • 我做到了。虽然,SSL 证书不在 chrome 的信任列表中,它说连接不是私有的,我必须点击继续,但根据 Facebook,没关系!
  • 是的,没关系,我正在以同样的方式运行,正在开发即时游戏,它在我的系统上运行良好。请让我知道您面临的确切错误是什么。
  • 我找不到具体的错误,它只是停留在 0% 加载,我尝试了控制台日志,似乎游戏甚至没有初始化!
【解决方案2】:

变量“game”似乎有问题。我找不到它是从哪里开始的。当我用“游戏”暂时禁用命令并且它不再停留在 0% 时。尝试调试该变量,您可能会解决问题。

【讨论】:

  • 我认为这不是问题,因为我禁用了 game.start() 行并且问题仍然存在
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多