0

So my game wants the players to have the ability to subscribe to a game bot and I'm using FBInstant.player.canSubscribeBotAsync() method. But everytime, it will return an error that state

Uncaught TypeError: FBInstant.player.canSubscribeBotAsync is not a function here is my code

FBInstant.player.canSubscribeBotAsync().then(function(yes){
    if(yes){
      FBInstant.player.subscribeBotAsync().then(function(){
        console.log('sub');
      }).catch(function(e)){}
    }
});

I tried using this code from FB developer doc

FBInstant.player.canSubscribeBotAsync().then(
  can_subscribe => console.log(can_subscribe)
);

but the result still the same.

1 Answers1

0

It seems that I tried to let the player subscribe when they click the button and this error appears. But when I switch it from letting the player click the subscribe button to asked when player finished loading the game, the error disappears. The program's flow look like this

window.onload = async () => {
      FBInstant.initializeAsync().then(()=>{
        FBInstant.startGameAsync().then((res)=>{
          FBInstant.player.canSubscribeBotAsync().then((canSub)=>{
            //Ask for sub or something
        }).catch(()=>console.log("Error"))
      })
})

But for me, this is a temporary fix since normally you should be able to call a function anywhere you want (working or not isn't my problem) and my problem is that I can only call FBInstant.player.canSubscribeBotAsync() inside FBInstant.initializeAsync() or FBInstant.startGameAsync() but not outside of them