Social Sharing

Welcome to the Facebook Instant Games SDK Tutorials. This series of tutorials covers many aspects of using the Facebook Instant Games SDK.

In this tutorial we will take a look at social sharing using the Facebook Instant Games SDK.

What is Social Sharing?

Social sharing is the process of users sharing information with other users via some medium such as Messenger or Facebook. Facebook Instant Games supports this via FBInstant.shareAsync(). From an IG perspective this is sharing things like their best scores, game invites, help requests, screenshots and so on. Lets take a look at an example:

[sourcecode language=”js”]
FBInstant.shareAsync({
intent: "SHARE",
image: base64_image_of_rubber_duck,
text: "Here is a free rubber duck my friend",
data: { gift: "rubber duck" },
})
.then(function(){
// Share dialog was successfully shown
}).catch(function(error) {
// Error occurred
});
[/sourcecode]

Calling shareAsync() opens a share dialog for the user, which enables them to share to various different channels including a message via Messenger and post via Facebook.

Note that if shareAsync() resolves without issue then it does NOT mean that the user successfully shared the post, this is deliberate to prevent rewarded sharing which goes against Facebook’s rules.

The parameters passed to shareAync() are described below:

  • intent (“INVITE” | “REQUEST” | “CHALLENGE” | “SHARE”) – The intent of the share (currently does nothing)
  • image string – base64 encoded image that will be shared
  • text string – Text of the message to be shared
  • data Object? – Meta data to be shared. Games launched from this share will pass this data into the game via the entry point data

Leave a Reply