Skip to content

Ads Module

This page explains how to integrate rewarded and interstitial ads using the Playol SDK. The SDK provides a streamlined monetization pipeline with automatic revenue tracking — no need for third-party ad networks, approval processes, or payout management. Everything is handled by the platform so you can focus on building your game.


📌 1. Use Cases

  • Rewarded ads: Users watch a full video to earn a reward (e.g., revive, coins, items, retries);
  • Interstitial ads: Shown after level completion, failure, or pause — generating passive revenue;
  • The SDK automatically determines ad fill status, skip behavior, and completion;
  • All ad flows invoke the afterAd callback, even if ads are skipped or unavailable;
  • Revenue is attributed to the current game and processed by the platform;
  • Default ad pacing: one request per 30 seconds (controlled by Google Ads logic).

🧩 2. Methods & Usage

🎥 Show Rewarded Ad

openRewardAd(callbacks)

Opens a rewarded ad. Users receive rewards after watching the full video.

js
window.playolSDK.ad.openRewardAd({
  beforeAd: () => console.log('Ad starting...'),
  adViewed: (duration) => console.log('Ad fully watched:', duration, 'seconds'),
  adDismissed: (duration) => console.log('Ad skipped, watched:', duration, 'seconds'),
  afterAd: (res) => console.log('Ad status:', res)
})

📌 Callback Reference:

CallbackTypeDescription
beforeAd() => voidTriggered before the ad plays
adViewed(duration?: number)Called when ad is fully watched
adDismissed(duration?: number)Called when user skips the ad
afterAd(msg: adMsg)Always triggered at ad completion

📦 adMsg Structure:

FieldTypeDescription
status`-101`-1: Not filled / 0: Skipped / 1: Watched
msgstringStatus message
durationnumber?View duration (in seconds) if present

⚠️ You should only grant rewards when status === 1.


📺 Show Interstitial Ad

openNormalAd(callbacks)

Displays a standard interstitial ad (no rewards), e.g. after pause or level end.

js
window.playolSDK.ad.openNormalAd({
  beforeAd: () => console.log('Interstitial ad starting'),
  afterAd: (res) => console.log('Ad result:', res)
})

📌 Notes:

  • Interstitials are non-skippable; no need to check ad status;
  • afterAd is always called, even when no ad is filled.

✅ Unified Ad Entry

openAd(adType, callbacks)

A generic method to call either type of ad.

js
window.playolSDK.ad.openAd('reward', callbacks)

📦 adType Options:

ValueDescription
'reward'Rewarded video ad
'normal'Interstitial ad

🧪 Adblock Detection

hasAdblock()

Detects if the current environment has an ad blocker enabled.

js
const isBlocked = await window.playolSDK.ad.hasAdblock()
if (isBlocked) {
  console.warn('Adblock detected. Consider prompting the user to disable it.')
}

📌 Tips:

  • You may limit certain features (e.g., skins, bonuses) to encourage users to disable ad blockers;
  • Ensure data is saved before prompting for a page refresh.

ScenarioRecommended Method
Revive after failureopenRewardAd()
Bonus after level clearopenRewardAd()
Ad break after pauseopenNormalAd()
Check for adblock usagehasAdblock()

📦 4. FAQ

Q: Will afterAd trigger if the ad fails to show?

A: Yes. Whether the ad is skipped, unavailable, or completed, afterAd will always be called with a status.

Q: How are ad frequencies controlled?

A: Ad pacing (e.g., 30s cooldown) is managed internally by the ad provider. You only need to trigger ads appropriately.

Q: How are ad revenues settled?

A: Revenue is tracked per game and distributed by the platform. Earnings and payout information will be available in the developer dashboard.

Q: Do ad methods support Promises?

A: Currently, all ad methods use callbacks. Promise/async support is planned for future versions.


👉 User ModuleGame ModulePayment ModuleInvite Module

Released under the MIT License