integration
Scannednpx machina-cli add skill Playgama/bridge-claude-plugins/integration --openclawPlaygama Bridge SDK Integration
Playgama Bridge is a cross-platform SDK for publishing HTML5 games across 20+ platforms including Playgama, YouTube, Yandex Games, Crazy Games, Poki, Facebook, Telegram, Xiaomi, and more.
Installation
Add the SDK script to the HTML <head>:
<script src="https://bridge.playgama.com/v1/stable/playgama-bridge.js"></script>
CDN options:
https://bridge.playgama.com/v1/stable/playgama-bridge.js- Recommended (latest v1.x.x)https://bridge.playgama.com/latest/playgama-bridge.js- Bleeding edgehttps://bridge.playgama.com/v1.27.0/playgama-bridge.js- Specific version
Initialization
bridge.initialize()
.then(() => {
// SDK ready
})
.catch(error => {
// Handle error
})
After game is fully loaded and ready for player interaction:
bridge.platform.sendMessage('game_ready')
Device
// Device type
bridge.device.type // 'mobile', 'tablet', 'desktop', 'tv'
Platform Detection
// Platform ID
bridge.platform.id
// Values: 'playgama', 'facebook', 'crazy_games', 'mock', etc.
// User language (ISO 639-1)
bridge.platform.language // 'en', 'ru', etc.
// Top-level domain
bridge.platform.tld // 'com', 'ru', null
// URL payload
bridge.platform.payload
// Server time (UTC milliseconds)
bridge.platform.getServerTime().then(result => console.log(result))
Platform Messages
bridge.platform.sendMessage('in_game_loading_started')
bridge.platform.sendMessage('in_game_loading_stopped')
bridge.platform.sendMessage('gameplay_started')
bridge.platform.sendMessage('gameplay_stopped')
bridge.platform.sendMessage('player_got_achievement')
Player
// Player ID (null if not authorized)
bridge.player.id
// Player name (null if unavailable)
bridge.player.name
// Player photos (array sorted by increasing resolution)
bridge.player.photos
// Platform-specific player data for verification
bridge.player.extra
Authorization
// Check if authorization is supported
bridge.player.isAuthorizationSupported
// Check if player is authorized
bridge.player.isAuthorized
// Authorize player
let options = {}
bridge.player.authorize(options)
.then(() => {
// Player successfully authorized
})
.catch(error => {
// Authorization failed or cancelled
})
Audio & Pause State
// Audio state
bridge.platform.isAudioEnabled
bridge.platform.on(bridge.EVENT_NAME.AUDIO_STATE_CHANGED, isEnabled => {
// Mute/unmute game audio
})
// Pause state
bridge.platform.on(bridge.EVENT_NAME.PAUSE_STATE_CHANGED, isPaused => {
// Pause/resume game
})
Storage
// Get single value
bridge.storage.get('key')
.then(data => console.log(data))
// Get multiple values
bridge.storage.get(['key1', 'key2'])
.then(data => console.log(data))
// Set single value
bridge.storage.set('key', 'value')
.then(() => { /* saved */ })
// Set multiple values
bridge.storage.set(['key1', 'key2'], ['value1', 'value2'])
.then(() => { /* saved */ })
// Delete
bridge.storage.delete('key')
bridge.storage.delete(['key1', 'key2'])
Banner Ads
// Check support
bridge.advertisement.isBannerSupported
// Show banner
let position = 'bottom' // 'top' or 'bottom'
let placement = 'menu' // optional
bridge.advertisement.showBanner(position, placement)
// Hide banner
bridge.advertisement.hideBanner()
// Banner state
bridge.advertisement.bannerState // 'loading', 'shown', 'hidden', 'failed'
bridge.advertisement.on(bridge.EVENT_NAME.BANNER_STATE_CHANGED, state => {
console.log('Banner state:', state)
})
Interstitial Ads
// Check support
bridge.advertisement.isInterstitialSupported
// Show interstitial
let placement = 'level_complete' // optional
bridge.advertisement.showInterstitial(placement)
// Minimum delay between interstitials (default: 60 seconds)
bridge.advertisement.minimumDelayBetweenInterstitial
bridge.advertisement.setMinimumDelayBetweenInterstitial(30)
// State tracking
bridge.advertisement.interstitialState // 'loading', 'opened', 'closed', 'failed'
bridge.advertisement.on(bridge.EVENT_NAME.INTERSTITIAL_STATE_CHANGED, state => {
if (state === 'opened') {
// Your logic
} else if (state === 'closed' || state === 'failed') {
// Your logic
}
})
Rewarded Ads
// Check support
bridge.advertisement.isRewardedSupported
// Show rewarded ad
let placement = 'double_coins' // optional
bridge.advertisement.showRewarded(placement)
// State tracking
bridge.advertisement.rewardedState
// States: 'loading', 'opened', 'closed', 'rewarded', 'failed'
bridge.advertisement.on(bridge.EVENT_NAME.REWARDED_STATE_CHANGED, state => {
if (state === 'opened') {
// Your logic
} else if (state === 'rewarded') {
// Grant reward to player
} else if (state === 'closed' || state === 'failed') {
// Your logic
}
})
// Current placement
bridge.advertisement.rewardedPlacement
In-App Purchases
// Check support
bridge.payments.isSupported
// Get catalog
bridge.payments.getCatalog()
.then(items => {
items.forEach(item => {
console.log('ID:', item.id)
console.log('Price:', item.price)
console.log('Currency:', item.priceCurrencyCode)
console.log('Value:', item.priceValue)
})
})
// Purchase
bridge.payments.purchase('product_id')
.then(purchase => console.log('Purchased:', purchase.id))
.catch(error => { /* cancelled or failed */ })
// Consume purchase (for consumable items)
bridge.payments.consumePurchase('product_id')
.then(purchase => console.log('Consumed:', purchase.id))
// Get purchased items
bridge.payments.getPurchases()
.then(purchases => {
purchases.forEach(p => console.log('Owned:', p.id))
})
Config example (playgama-bridge-config.json):
{
"payments": [
{
"id": "coins_100",
"playgama": { "amount": 1 },
"playdeck": { "amount": 1, "description": "100 Coins" }
}
]
}
Leaderboards
// Check type
bridge.leaderboards.type
// 'not_available', 'in_game', 'native', 'native_popup'
// Set score
bridge.leaderboards.setScore('leaderboard_id', 1000)
.then(() => { /* saved */ })
// Get entries (only when type = 'in_game')
bridge.leaderboards.getEntries('leaderboard_id')
.then(entries => {
entries.forEach(entry => {
console.log('Name:', entry.name)
console.log('Score:', entry.score)
console.log('Rank:', entry.rank)
console.log('Photo:', entry.photo)
})
})
// Show native popup (only when type = 'native_popup')
bridge.leaderboards.showNativePopup('leaderboard_id')
Config example:
{
"leaderboards": [
{
"id": "high_score"
}
]
}
Social Features
Share
bridge.social.isShareSupported
let options = {}
switch (bridge.platform.id) {
case 'vk':
options = { link: 'https://...' }
break
case 'facebook':
options = { image: 'base64...', text: 'Check this game!' }
break
}
bridge.social.share(options)
Invite Friends
bridge.social.isInviteFriendsSupported
bridge.social.inviteFriends({ text: 'Join me!' })
Join Community
bridge.social.isJoinCommunitySupported
let options = {}
switch (bridge.platform.id) {
case 'vk':
case 'ok':
options = { groupId: 123456 }
break
}
bridge.social.joinCommunity(options)
Other Social Methods
// Add to favorites
bridge.social.isAddToFavoritesSupported
bridge.social.addToFavorites()
// Rate game
bridge.social.isRateSupported
bridge.social.rate()
// Add to home screen
bridge.social.isAddToHomeScreenSupported
bridge.social.addToHomeScreen()
// Create post
bridge.social.isCreatePostSupported
bridge.social.createPost(options)
// Check external links
bridge.social.isExternalLinksAllowed
Best Practices
- Always call
bridge.platform.sendMessage('game_ready')when game is loaded - Mute/restore game audio when audio state changed
- Show ads at natural breakpoints (level transitions, player death), not during gameplay
- Check
isSupportedbefore using features - Handle pause state changes to pause/resume game
- Use platform-specific options for social features
- Grant rewards only when rewarded ad state is 'rewarded'
Source
git clone https://github.com/Playgama/bridge-claude-plugins/blob/main/plugins/playgama-bridge/skills/integration/SKILL.mdView on GitHub Overview
Playgama Bridge provides a cross-platform SDK to publish HTML5 games across 20+ platforms. It enables cross-platform publishing, ads, in-app purchases, leaderboards, and social features through a single integration. This skill covers installation, initialization, platform detection, messaging, storage, and advertising to streamline multi-platform development.
How This Skill Works
You include the Bridge script in the HTML head and call bridge.initialize() to prepare the SDK. After readiness, you can query bridge.device, bridge.platform, and bridge.player for context, send platform messages like 'game_ready', and use storage, advertisement, and authentication APIs to enable features across platforms. The SDK also provides events for audio and pause state, plus server time access via bridge.platform.getServerTime().
When to Use It
- Building an HTML5 game that must publish across 20+ platforms with a single integration
- Adding banner ads or other ad formats through the Bridge
- Implementing in-app purchases, leaderboards, or social features via the Bridge
- Detecting platform, language, and domain to tailor UI and localization
- Managing player data, authorization, and cross-platform storage
Quick Start
- Step 1: Add the SDK script to your HTML head: <script src="https://bridge.playgama.com/v1/stable/playgama-bridge.js"></script>
- Step 2: Initialize the SDK and await readiness: bridge.initialize().then(() => { /* SDK ready */ }).catch(err => { /* Handle error */ })
- Step 3: Use core APIs (e.g., platform detection, storage, ads) to implement features like game_ready messaging or banner ads
Best Practices
- Include the bridge script in the HTML head from the recommended CDN
- Initialize early with bridge.initialize() and handle both success and error paths
- Use platform and device data (bridge.device, bridge.platform) to adapt UI and flows
- Persist and retrieve data with bridge.storage to support cross-platform progress
- Listen for and respond to events (AUDIO_STATE_CHANGED, PAUSE_STATE_CHANGED, BANNER_STATE_CHANGED) to keep UI in sync
Example Use Cases
- Customize UI based on bridge.platform.language and bridge.platform.id for localization and platform-specific behaviors
- Show a bottom banner ad on menu open using bridge.advertisement.isBannerSupported and bridge.advertisement.showBanner
- Store player progress with bridge.storage.set and load it on startup with bridge.storage.get
- Authorize the player with bridge.player.authorize() before submitting achievements or entering leaderboards
- Sync in-game time with bridge.platform.getServerTime() to schedule time-based events accurately