0

I have a super simple HTML5 game that I'm trying to test within facebook embedded player, but the game always stuck at 0% loading and it doesn't log the word "test" that I have at the beginning meaning that it's not even initialized. why is that?

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

I have replaced the GAME_ID with mine

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>

2 Answers2

0

Facebook Instant game will work on HTTPS, one of your chrome browser tab should open below the localhost URL

https://localhost:8080

Then in the next tab, you should run the below URL, now it will work fine.

https://www.facebook.com/embed/instantgames/YOUR_GAME_ID/player?game_url=https://localhost:8080
radhey shyam
  • 759
  • 6
  • 9
  • I did that. although , SSL certificate isn't in the trust list in chrome and it says the connection isn't private and I have to click proceed anyway but according to Facebook, that's okay! –  Jan 08 '21 at 05:17
  • Yes, it is ok, I am running the same way, working on Instant games, it's running fine on my system. Let me know what is the exact error you are facing, please. – radhey shyam Jan 08 '21 at 06:54
  • i can't find a specific error, it just stuck at 0% loading and I tried console log and it appears that the game is not even initialized! –  Jan 08 '21 at 13:17
0

it seems to have problem with the variable "game." I do not find where it is initiated. When I temporally disable commands with "game" and it no longer stucks at 0%. Try debugging that variable, you may resolve the problem.

  • I don't think this is the problem as I have disabled game.start() line and the problem still exists –  Jan 08 '21 at 18:26