Skip to content

Quick Start

This page guides you through properly initializing the Playol SDK in your game and configuring essential parameters.

The Playol SDK is a purpose-built integration solution for HTML5 games. It allows you to seamlessly integrate user accounts, payments, data storage, ads, internationalization, and more — without writing any server-side code.

All you need to do is initialize it once at the game entry point to unlock full platform capabilities.


📦 1. Include the SDK Script

html
<script async src="https://static.playol.com/sdk/playol-sdk-v2.0.5.js"></script>

The SDK is loaded asynchronously from the platform and automatically mounted to a global instance on window.playolSDK.


🚀 2. Check if the SDK Loaded Successfully

To prevent runtime errors caused by network issues or failed script loading, it is recommended to add a check like the following:

html
<script>
if (window.playolSDK === undefined) {
  throw new Error('Playol SDK failed to load. Please check your network or script link.');
}
</script>

⚙️ 3. Inject Initialization Parameters

After the SDK has loaded, call the initSDKParam method to inject essential configuration like appKey and testMode.

html
<script>
window.playolSDK.initSDKParam({
  appKey: 'your-app-key',      // Unique identifier for your game on the platform
  testMode: 'on'               // Enable test mode (default: off)
})
</script>

Parameter Details:

ParameterTypeRequiredDescription
appKeystring✅ YesUnique game identifier provided by the platform
testModestring❌ NoOptional: 'on' / 'off', defaults to off

💡 Test mode is useful for local development and debugging. Be sure to turn it off in production environments.


✅ 4. What the SDK Does Automatically (Post Initialization)

Once initialized, the SDK will automatically:

  • Retrieve and listen for user info changes;
  • Sync platform language settings for internationalization;
  • Inject invite, payment, and ad parameters;
  • Initialize local data sync mechanisms (via the data module);
  • Register event hooks for gameplay analytics.

You can access platform-injected parameters like this:

js
const appSecret = window.playolSDK.appSecret
const channelID = window.playolSDK.channelID

📘 Field Descriptions:

FieldTypeDescription
appSecretstringPlatform-issued SDK public key, used for authentication and data verification.
It is read-only and typically passed to the backend for security purposes.
channelIDstringAd channel identifier, used to track the ad network or traffic source.
Automatically injected by the platform for attribution and revenue analytics.

⚠️ Both fields are read-only and auto-injected by the platform, and can be safely passed to your backend if needed.


Here’s a recommended initialization structure to ensure proper loading, fallback handling, and parameter injection:

html
<script async src="https://static.playol.com/sdk/playol-sdk-v2.0.5.js"></script>

<script>
  window.addEventListener('load', () => {
    if (window.playolSDK === undefined) {
      throw new Error('Playol SDK failed to load!');
    }

    // Inject initialization parameters
    window.playolSDK.initSDKParam({
      appKey: 'your-app-key',
      testMode: 'on'
    });

    // Optional: Get user info
    const userInfo = window.playolSDK.user.userInfo;
    console.log('User info:', userInfo);
  });
</script>

📌 Tips & Best Practices

  • Make sure the SDK script is included in the top-level <head> or <body> section of your HTML to avoid being ignored by build tools;
  • If you’re using Vue, React, Uniapp, or similar frameworks, check for window.playolSDK in your main entry file;
  • All Playol SDK APIs are available under window.playolSDK.*. Each module is documented in detail in the following sections.

Next steps: 👉 i18n Module | User Module | Payment Module

Released under the MIT License