跳转到内容

AdsAPI

此内容尚不支持你的语言。

Defined in: services/ads.ts:68

new AdsAPI(takeover): AdsAPI

Defined in: services/ads.ts:78

Takeover

The app-wide pause/silence ceremony. Shared rather than private: a store overlay opening during an ad is one covered game, not two (see services/takeover.ts).

AdsAPI

get available(): boolean

Defined in: services/ads.ts:84

Whether SOME ad source exists here — the platform’s or an installed provider. False is what a menu reads to hide its “watch ad” button.

boolean


get showing(): boolean

Defined in: services/ads.ts:89

True while an ad covers the game (the clock is paused, audio suspended).

boolean

preloadRewarded(adUnitId): Promise<void>

Defined in: services/ads.ts:105

Warm a rewarded unit so showRewarded has a fill ready. Best-effort: a preload failure only means show() pays the load.

string

Promise<void>


setProvider(provider): void

Defined in: services/ads.ts:98

Install (or clear with null) an AdProvider that answers INSTEAD of the platform. The editor’s play mode installs the mock; a native shell with a mediation SDK installs a real one. Clearing drops cached units.

AdProvider | null

void


showInterstitial(adUnitId): Promise<void>

Defined in: services/ads.ts:124

Show an interstitial; resolves when it closed. Same contract as showRewarded, minus the reward.

string

Promise<void>


showRewarded(adUnitId): Promise<PlatformRewardedAdResult>

Defined in: services/ads.ts:116

Show a rewarded video and resolve with whether the reward was earned — after the ad closed and the game is running again. Rejects when this platform has no ad source (check available first) or the host genuinely has no fill; the game state is restored in every path.

string

Promise<PlatformRewardedAdResult>