I am trying to implement the invite and challenge friends functionality. I’ve read on this forum that this should be done via the “fbinstant.choose_context”. So I implemented the method, uploaded the game and I am now testing on Facebook.
When the user presses the button, which calls this function, the user sees the following:
So all seems to be good here. When the invite is sent, Facebook nicely tells me that I have started a game with friend X in Messenger at the top of the game. However, the invite/challenge is never sent in the Messenger. So no body sees any of the invites/challenges.
The code I’ve written to achieve this looks like this (sharing works fine by the way!):
if message.intent == fbinstant.SHARE_INTENT_SHARE then
local im = sys.load_resource("/fish_game/assets/marketing/share_img_base64.json")
local payload =
{
["intent"] = message.intent,
["image"] = im,
["text"] = message.text
}
payload = rxijson.encode(payload)
fbinstant.share(payload, function(self, success)
print("was it a success?")
print(success)
end)
elseif message.intent == fbinstant.SHARE_INTENT_INVITE then
fbinstant.choose_context(nil, function(self, id, type)
print("chose a context....INVITE!")
print(id)
print(type)
end)
elseif message.intent == fbinstant.SHARE_INTENT_CHALLENGE then
fbinstant.choose_context(nil, function(self, id, type)
print("chose a context....CHALLENGE!")
print(id)
print(type)
end)
end
When I look at the browser console, I do not see the print messages, by the way. I was wondering if I am doing this correctly on the Defold side.
Are you creating a debug build? Release builds will not show any output. Can you add a print() right before calling fbinstant.choose_context() as well?
Nope. Not a requirement while testing. But to get the game as small as possible it should be a release build (and with anything from the engine you don’t need also removed).
What’s interesting here is that after the invite is sent, it shows the temporary notification pop-up on the top of the game screen (like it did before), but this time “print(“Succesfully updated the content for INVITE!”)” is never called. So fbinstant.update seems to fail if uploaded to facebook. It does however work if I launch the game from the editor by building it: