Skip to main content

Adding a Game

To use the SDK features:

  1. Add the game in the game control panel
  2. Enter the name of the game and click the "Add game" button.
  3. After that, you will be taken to the game control panel interface.

Code installing

To embed SDK in the game:

  1. Add the script inindex.html
  2. Indicate projectId and publicToken. They must correspond to the ID of the project and public key from the game control panel:

index.html
// install code before body close tag
<script async src="https://gamepush.com/sdk/game-score.js?projectId=2782&publicToken=xT3RpsJMXpKWHPrTWkv3VBeHJKvCBccT&callback=onGPInit"></script>
<script>
window.onGPInit = (gp) => {
// ready
};
</script>

SDK initialization

After initializing the SDK, the onGPInit function will be called, in which a ready-to-use SDK instance with all managers will be passed as an argument. For correct interaction with the player, you need to wait synchronizing the player with the server.

index.html
// Add GS script url
<script async src="https://gamepush.com/sdk/game-score.js?projectId=4&publicToken=xT3RpsJMXpKWHPrTWkv3VBeHJKvCBccT&callback=onGPInit"></script>
<script>
window.onGPInit = async (gp) => {
// Wait while the player syncs with the server
await gp.player.ready;
// Show the ad preloader and wait until it ends
await gp.ads.showPreloader();
// Show the sticky banner (then it will update itself)
gp.ads.showSticky();

// You can start the game :)
};
</script>

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!