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 )
end
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).