Social

Working with social features is implemented via connector.social interface.

Share

Shows a window inviting the player to share.

Supported Platforms

  • VK Games
  • OK Games
  • Kongregate
  • Facebook Instant Games
  • MSN
  • Facebook
  • Fotostrana
  • Mobage
  • SP Mobage
  • My World (except for iOS)
  • Draugiem
  • Plinga
  • Wortal
  • Mygames

To get a list of available share channels you can use

const channels = connector.platform.listShareChannels();
// ["share", "shareNative", "invite"]

"share" and "invite" channels use social network capabilities while "shareNative" uses platform's native share, e.g. Android or iPhone share method. "share" and "invite" also require the user to be logged into a social network. If the user isn't logged in, calling share will attempt to log them in and will show the share dialog if the login attempt is successful.

When calling share you can provide title, text and image. If title is omitted, title tag will be used. You can specify a channel for share, if omitted a first available channel will be used. For VK you need to provide image in the attachment format photo123456_123456.

const success = await connector.platform.share({
  channel: "share",
  title: "Level completed!",
  text: "I passed a level! It's an amazing game, you should try it!",
  image: "https://example.com/img.png"
})

if (success) {
  // Share successful
}

You can also subscribe to on share event

connector.platform.on("share", (success, channel) => {
 if (success) {
   // Share successful
 }
});

Join community

Shows the player an overlay with the opportunity to join the community (if the platform allows) or opens a link to the community in a new tab.

Supported Platforms

  • VK Games
  • OK Games
  • Facebook Instant Games
  • Facebook
  • Fotostrana
  • Mobage
  • SP Mobage
  • My World (except for iOS)
  • Draugiem
if (connector.social.canJoinCommunity) {
  // Join community is available
}

Platform with native functionality

  • OK Games
  • Facebook Instant Games
if (connector.social.isSupportsNativeCommunityJoin) {
  // Native join community is available
}

Join community

const success = await connector.social.joinCommunity();
if (success) {
  // Join community success
}

You can also subscribe to on join community event:

connector.social.on("joinCommunity", (success) => {
if (success) {
  // Join community success
}
});

Login

Login user on the platform

const success = await connector.social.login();
if (success) {
  // Login success
}

// Or you can subscribe to on login event
connector.social.on("login", { oldId, newId } => {
  // Login success
})

You can check whether the player is logged in with

connector.social.isLoggedIn();

Members

(static) isSupportsNativeRequest :Boolean

Are native requests supported on this platform

Type:
  • Boolean

(static) isSupportsNativeCommunityJoin :Boolean

Are native community join supported on this platform

Type:
  • Boolean

(static) canJoinCommunity :Boolean

Whether player can join community on this platform

Type:
  • Boolean

Methods

(static) listShareChannels() → {Array.<string>}

Get a list of available share channels

Returns:
Type: 
Array.<string>

(static) share(options) → {Promise.<Boolean>}

Opens share dialog

Parameters:
NameTypeDescription
optionsobject

Options

Properties
NameTypeDescription
titlestring

Title

textstring

Text

imagestring

Image URL

channelstring

Share channel - "nativeShare", "share", "invite"

linktextobject

Text for link, for Plinga only

subTitleobject

Sub title, for Draugiem only

Returns:
Type: 
Promise.<Boolean>

(static) isLoggedIn() → {Boolean}

Is player logged in

Returns:
Type: 
Boolean

(static) login() → {Promise.<Boolean>}

Login

Returns:
Type: 
Promise.<Boolean>

(static) joinCommunity() → {Promise.<Boolean>}

Join community

Returns:
Type: 
Promise.<Boolean>

(static) request(options) → {Promise.<Boolean>}

Send request to friends

Parameters:
NameTypeDescription
optionsobject

Options

Properties
NameTypeDescription
titlestring

Title

textstring

Text

imagestring

Image URL

toArray.<string>

List of friend IDs

Returns:
Type: 
Promise.<Boolean>