Social actions
Overview
We suggest using social actions for audience multiplication — share, post and invite friends to the game. Platforms such as VK and OK allow you to use the tools built into the platform. The rest of the platforms will imitate the functionality through the usual link sharing with the ability to add a comment and sometimes pictures.
The list of supported social networks and messengers for sharing:
- Telegram
- Vkontakte
- Odnoklassniki
- Viber
For better parsing of games by messengers and social networks, we recommend placing Open Graph meta tags in the game. And also fill in the title and description. This is useful in terms of SEO optimization. An example of placing meta tags is shown below:
// Fill in the basic information about the game
<title>My awesome game 2</title>
<meta name="og:title" content="My awesome game 2">
<meta name="description" content="There are not enough words to describe the awesomeness of the game">
<meta name="og:description" content="There are not enough words to describe the awesomeness of the game">
<meta name="og:image" content="/img/ogimage.png">
To check that sharing is allowed and supported on the platform:
// Is sharing supported
gp.socials.isSupportsShare
Share
By default, you can share a game link through share
method calling. We will define the link ourselves depending on the platform and substitute the required text, it is taken from the meta tag og:title
or tag title
.
// Is native sharing supported
gp.socials.isSupportsNativeShare
In platforms without native support for this method, there will be used an overlay with an offer to share on social networks and messengers.
gp.socials.share();
Share with free text adding:
gp.socials.share({
text: `I tapped the square 73 times in 5 seconds!
Now I am number 23 in "Fastest Fingers" list.
Can you beat out me?`
});
Share with an arbitrary link adding:
gp.socials.share({
url: `${gp.app.url}?invitedBy=${gp.player.id}`
});
Share with an optional picture adding:
gp.socials.share({
image: 'https://gamepush.com/img/ogimage.png'
});
Support for images through native methods of social networks is implemented only in Vkontakte through the attachment format photo123456_123456
and Odnoklassniki through the attachment format 123456
, or URL of images uploaded through GamePush to the platform (gp.images.upload()
) for the rest, the image parameter will be ignored, only url and text are available.
Fully customizable sharing:
gp.socials.share({
text: 'Join me in the game "My awesome game 2"',
url: gp.app.url,
image: 'https://gamepush.com/img/ogimage.png'
});
Post
As opposed to share method, the post method involves posting to the player’s friends news feed.
// Is native posting supported
gp.socials.isSupportsNativePosts
On the platforms without native supporting for this method, there will be used an overlay with an offer to share, as in the case of the share
method.
The usage logic duplicates the share
method.
gp.socials.post();
Fully customizable post:
gp.socials.post({
text: 'Join me in the game "My awesome game 2"',
url: gp.app.url,
image: 'https://gamepush.com/img/ogimage.png'
});
Invite friends
Shows the player a friends list to whom you can send the invitation.
// Are native invites supported
gp.socials.isSupportsNativeInvite
On the platform without native supporting of this method, there will be used an overlay with the offer to invite friends, as in the case of share
and post
methods.
The usage logic duplicates the share
method.
gp.socials.invite();
Customizable text for some platforms:
gp.socials.invite({
text: 'Join me in the game "My awesome game 2"',
});
The method accepts the same object as in the case of share
and post
, but today only text
is used.
Join community
Shows the player an overlay with the option to join the community (if the platform allows) or opens a community link in a new tab.
// check is community join is available on platform
gp.socials.canJoinCommunity
// check is native community join is supported
gp.socials.isSupportsNativeCommunityJoin
Join community:
gp.socials.joinCommunity();
Working with parameters for sharing
You may need to create a link to invite a player that contains the inviter's ID and a gift for the invited player. To do this, you need to add these parameters to the game link on the platform. All platforms require different ways of forming URLs. We have combined the creation of links into one method. When you follow this link, all previously passed parameters are available to you.
Create a sharing link
const shareUrl = gp.socials.makeShareUrl({
// any of your parameters
fromId: gp.player.id,
gift: 'GOLD_SWORD_X5'
});
// https://vk.com/app7869399#eyJmcm9tSWQiOjE4MDcwMTksImdpZnQiOiJHT0xEX1NXT1JEX1g1In0=
Read parameters when following the link
// any of your parameters specified in the link
const fromId = gp.socials.getShareParam('fromId'); // 123456
const gift = gp.socials.getShareParam('gift'); // "GOLD_SWORD_X5"
Stay in Touch
Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.
GamePush Community Telegram
: @gs_community.
For your suggestions e-mail
: [email protected]
We Wish you Success!