Contextual leaderboards on Facebook Instant


I’ve got this working and wanted to share a couple of gotchas I had.

To load and save contextual scores the leaderboard name and context needs to be concatenated for it to work, like this:

local context_id, context_type = fbinstant.get_context()
if context_id then
    local name = "Leaderboard Name"
    local name_and_context = name .. "." .. context_id	
    fbinstant.set_leaderboard_score( name_and_context, score, "", on_set_leaderboard_score )

This is from the docs:

fbinstant.set_leaderboard_score(name, score, extra_data, callback)

Note that the parameter extra_data is required fore the score to be saved (it can’t be nil).


Hmm, did you get an error when it was nil?


Locally no, and when testing on Facebook Instant I get nothing in the browser output window (at all). It was a little tricky troubleshooting because of this!


Please create a ticket on the GitHub page for the extension. I’d like to add a check for this parameter.