简体   繁体   中英

Facebook Messenger Instant Games cannot fetch from or post to leaderboards

I am trying to port my first game to messenger instant, but I am totaly unable to post or fetch any scores. I have created both global and context related leaderboards, but no luck with either of them. I stil get ' no leaderboard found error'. Am I missing something?

Here is my project flow:

  • calling FBInstant.initializeAsync and loading all assets
  • once assets are loaded I call FBInstant.startGameAsync
  • now in code I am trying to post score

     function FacebookPostScore(score, leaderboard) { LOG('FacebookPostScore'); FBInstant .getLeaderboardAsync(leaderboard) .then(function(leaderboard){ console.log(leaderboard.getName()); return leaderboard.setScoreAsync(score, '{test: "1", test2: 3}'); }) .then(function(){ console.log('Score saved') }) .catch(function(error){ console.log('ERROR : ' + JSON.stringify(error)); }); }; 
  • when I am playing SOLO, context ID is null and I am trying to use GLOBAL leaderboard FacebookPostScore(1000, 'get10')

  • when I am playing in group, I am trying to use contextual leaderboard FacebookPostScore(1000, 'main.' + FBInstant.context.getID()

Both times I get only error

ERROR : {"code":"LEADERBOARD_NOT_FOUND","message":"A leaderboard with the name \\"main.1692542424140140\\" was not found"}

ERROR : {"code":"LEADERBOARD_NOT_FOUND","message":"A leaderboard with the name \\"get10\\" was not found"}

This is how it looks in chrome console

I was almost a day, in the end I managed to save a score by creating a test application of the same "application -test1", create a leaderboards and I succeeded in saving it. I will try creating a new application from scratch maybe that is the solution. I'll let you know if I'm successful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM