P00LS Games SDK Help

Getting started

Unity bridge is open source and available on GitHub

It comes with a fake project, aiming at showcasing a few features.

Install P00LS Games SDK

  1. Target WebGL platform

  2. Adds the P00LSGames package:

    • Open Unity Package Manager

    • Click the + button

    • Choose Add package from git URL

    • Enter https://github.com/p00ls-games-hosting/unity-bridge.git?path=io.p00ls.games

  3. Import the P00LS WebGL Template

    • Select Services | P00LS | Import WebGL template

    • Select Services | P00LS | Reset Template variables

  4. Drag and drop prefab P00lsGamesSDK in your scene from Packages/P00LS Games SDK/Prefabs folder

npm install @p00ls-games/sdk
import { p00lsGamesSdk } from '@p00ls-games/sdk';

P00LS provides both an ES and UMD bundled version :

<script type="module"> // static import import {p00lsGamesSdk} from 'https://cdn.jsdelivr.net/npm/@p00ls-games/sdk@4/index.es.js'; // or dynamic import const {p00lsGamesSdk} = await import(`https://cdn.jsdelivr.net/npm/@p00ls-games/sdk@${sdkVersion}/index.es.js`); </script>

To access the UMD version, replace .es by .umd

Setup

  1. Bind the P00lsGamesSDK into your script (or use any other means you prefer to access the SDK instance)

  2. You're all set, you can now use the SDK in your project.

Keep in mind this is an aysnc operation, so you should wait for the SDK to be fully initialized before attempting any action on it.

(async function() { const sdk = await p00lsGamesSdk(); // Tells p00ls games sdk your game is operational. Mandatory call. sdk.tma.ready(); /* Saves sdk instance somewhere you can access it, or pass it along your own setup function. You should avoid if possible storing it in global context. */ })();

Configure in-app purchases

Given how telegram invoices work, you need to implement a global callback that will receive all invoices feedbacks.

private void Awake() { p00lsGamesSdk.OnPurchase += OnPurchase; } private void OnPurchase(PurchaseResult result) { if (result.status == "paid") { gameState.DoSomething(); } }
sdk.purchase.onPurchase(purchaseResult => { if(purchaseResult.status == 'paid') { } });

Add your callback to Bridge.OnPurchase with your action early in the game lifecycle, and you're all set.

Configuration

SDK configuration is implicit and will vary depending on the environment.

Last modified: 15 March 2025