Ads: Yes2SDK.ads
Unified interface for interstitial, rewarded, and banner ads. Interstitials run at natural break points; rewarded ads run only when the player opts in.
Always call gameplayStop() before an ad and gameplayStart() after, pause your game in the before-ad callback, and resume in the after-ad callback (afterAd, Defold after_ad), which also runs after a no-fill. Unity drops afterAd after a no-fill, so also resume in the no-fill path there (Unity: onError with NoFill, see Unity). Grant rewards only in the "viewed" callback.
Methods (Core)
| Signature | Description |
|---|---|
showInterstitial(placement: string, callbacks?: AdCallbacks): Promise<void> | Show a full-screen interstitial. placement must be non-empty. Resolves when the ad finishes. |
showRewarded(placement: string, callbacks?: AdCallbacks): Promise<void> | Show a rewarded video. placement must be non-empty. Resolves when the ad finishes. |
showBanner(position?: BannerPosition): Promise<void> | Show a banner. position is "top" or "bottom" (default "bottom"). |
hideBanner(): void | Hide the current banner. |
isInterstitialSupported(): boolean | Whether interstitials are supported. |
isRewardedSupported(): boolean | Whether rewarded ads are supported. |
isBannerSupported(): boolean | Whether banner ads are supported. |
isRewardedAdAvailable(): boolean | Best-effort readiness hint. A coarse "SDK loaded" check on most platforms; showRewarded can still no-fill. |
isAdBlocked(): boolean | Whether an ad blocker is detected. false if unsupported. |
AdCallbacks (all optional)
| Field | Type | Description |
|---|---|---|
beforeAd | () => void | Before the ad shows. Pause the game. |
afterAd | () => void | After the ad finishes. Resume the game. |
adDismissed | () => void | User dismissed early (rewarded). |
adViewed | () => void | User watched the full ad (rewarded). Grant the reward here. |
noFill | () => void | No ad was available to show. |
BannerPosition = "top" | "bottom"
Platform support
| Method | Poki | GameDistribution | CrazyGames | Yandex | YouTube | Jest |
|---|---|---|---|---|---|---|
showInterstitial | Ready | Ready | Ready | Ready | Ready | None³ |
showRewarded | Ready | Ready | Ready | Ready | Ready | None³ |
showBanner | None | None | Ready | Ready | None | None⁴ |
hideBanner | None | None | Ready | Ready | None | None |
isInterstitialSupported | Ready | Ready | Ready | Ready | Ready | None⁵ |
isRewardedSupported | Ready | Ready | Ready | Ready | Ready | None⁵ |
isBannerSupported | None | None | Ready | Ready | None | None⁵ |
isRewardedAdAvailable | Partial | Partial | Partial | Partial | Partial | None⁵ |
isAdBlocked | Ready¹ | None | None² | None | None | None |
Platform mapping:
- Poki:
PokiSDK.commercialBreak/rewardedBreak. No banner. ¹isAdBlockedcallsPokiSDK.isAdBlocked()if present. - GameDistribution:
gdsdk.showAd("interstitial" | "rewarded"), resolved onSDK_GAME_STARTwith a 30s timeout safety net; rewarded grants onSDK_REWARDED_WATCH_COMPLETE. No banner. - CrazyGames:
sdk.ad.requestAd("midgame" | "rewarded"); banners viasdk.banner.*;hasAdblock()is real. - Yandex:
ysdk.adv.showFullscreenAdv/showRewardedVideo/showBannerAdv.!wasShownmaps tonoFill. - YouTube:
ytgame.ads.requestInterstitialAd()/requestRewardedAd(placement). No banner. - Jest: no in-game ads. See ³ to ⁵ and the Jest guide.
isRewardedAdAvailable is Partial on the ad platforms: it only checks that the platform ad object exists; there is no true readiness signal, so a true result can still no-fill.
² CrazyGames detects ad blocking asynchronously (its async hasAdblock()), not through a synchronous isAdBlocked. The unified ads.isAdBlocked() has no synchronous answer to report there, so it returns false for CrazyGames. Use the platform's own adblock handling instead.
³ Jest has no in-game ads, but the calls stay safe to keep in shared code. In TypeScript and Defold every interstitial and rewarded request calls noFill and then afterAd straight away, and the promise resolves. beforeAd is never called and no reward is granted. Unity reports the same no-fill as onError with error.Code == "NoFill" and does not call afterAd afterwards (see Unity).
⁴ Throws FEATURE_NOT_SUPPORTED on Jest.
⁵ Returns false on Jest. Use these checks to hide ad buttons and reward offers there.
Unity (C#)
Yes2SDK.Yes2SDK.Ads (Yes2SDKAds). Banner uses a BannerPosition enum (Top, Bottom).
| Signature | Description |
|---|---|
void ShowInterstitial(string placement, string description, Action beforeAd = null, Action afterAd = null, Action<Error> onError = null) | Rejects with InvalidParams if another ad is in flight. |
void ShowRewarded(string placement, string description, Action beforeAd = null, Action afterAd = null, Action adDismissed = null, Action adViewed = null, Action<Error> onError = null) | adViewed = grant reward; adDismissed = no reward. |
void ShowBanner(BannerPosition position = BannerPosition.Bottom, Action onShown = null, Action<Error> onError = null) | |
void HideBanner(Action onHidden = null, Action<Error> onError = null) | |
bool IsAdBlocked() | |
bool IsAdShowing() | True while an interstitial/rewarded call is in flight. |
bool IsRewardedAdAvailable() | Best-effort readiness hint. |
bool IsInterstitialSupported() / bool IsRewardedSupported() | Whether the platform serves the format at all. False on Jest. |
No fill in Unity. A no-fill arrives as onError with error.Code == "NoFill". Its error.ErrorCode is Unknown, so check Code. Once onError fires the ad is complete, and a later platform afterAd is dropped. Resume the game in onError on a no-fill, and in afterAd only when an ad actually ran. On Jest no ad ever runs, so every ad call takes the onError path.
Yes2SDK.Yes2SDK.Ads.ShowRewarded("double_coins", "Double your coins",
beforeAd: () => PauseGame(),
afterAd: () => ResumeGame(),
adViewed: () => GrantReward(),
onError: error =>
{
// error.Code == "NoFill" on Jest and whenever no ad is available.
ResumeGame();
});
Defold (Lua)
A Lua-side _ad_in_flight flag rejects a second concurrent ad call (logs a warning and fires that call's no_fill).
| Signature | Description |
|---|---|
yes2sdk.ads_show_interstitial(placement, before_ad, after_ad, no_fill) | no_fill fires on no ad / concurrent rejection. |
yes2sdk.ads_show_rewarded(placement, before_ad, after_ad, ad_dismissed, ad_viewed, no_fill) | Grant rewards in ad_viewed, not after_ad. |
yes2sdk.ads_is_ad_showing() | True while a call is in flight (Lua-side flag). |
yes2sdk.ads_is_rewarded_ad_available() | Best-effort readiness hint. |
yes2sdk.ads_is_interstitial_supported() / yes2sdk.ads_is_rewarded_supported() | Whether the platform serves the format at all. false on Jest. |
after_ad always follows no_fill, so resume the game in after_ad only. The one exception is a call rejected because another ad is still in flight: it gets no_fill alone. On Jest every ad call takes the no_fill then after_ad path.
Defold has no banner functions in the
ads_*namespace (banners are a separate module; see banners.md).