am working on the Facebook leaderboard for my game but FBInstant.context.getID(); this line of code returning me null value anyone has solution or git hub project using cocos 2.4.6 version please help me solve this.
const LEADERBOARD_NAME = “LEADERBOARD_NAME”;
FBInstant.initializeAsync();
FBInstant.startGameAsync();
contextID = FBInstant.context.getID();
console.log("fbinstance"+contextID);
FBInstant.getLeaderboardAsync(LEADERBOARD_NAME + '.' + contextID)
.then(function(leaderboard) {
console.log(leaderboard.getName());
return leaderboard.setScoreAsync(Globals.Score, '{race: "elf", level: 3}');
})
.then()
.catch(function(error) {
display.error('Leaderboard is not found in app configuration');
});
you can obtain contextid only if you are connected with someone
like play with friends, Facebook have updated their API.
if you refer the above link, you see that there are four context types
you can get context id 3 out of 4, leaving solo without any context id i.e, NULL
so for solo leaderboard you have to use your own server to store