Skip to content
Browse Docs and Help
how-to

Integrate optional ad requests without depending on fill

Handle the ad SDK safely while distinguishing simulation from live demand.

On this page

Availability first

An ad API call is not evidence that a live ad network is enabled. Previews and playtests do not show real ads or earn. The SDK panel can simulate outcomes. Kids games never offer rewarded ads.

Interstitials

  1. Finish an actual gameplay segment and call gameplayStop().
  2. Request ads.interstitial() at that natural break.
  3. Handle shown: false as a normal result.
  4. Let pause and resume handlers control your loop and audio.
  5. Call gameplayStart() only when the next gameplay segment starts.

The host applies eligibility and timing rules. Do not implement timers that assume an ad is guaranteed to appear.

Rewarded action

import llvls from '@llvls/sdk';

async function requestExtraLife(): Promise<boolean> {
  if (!(await llvls.ads.rewardedAvailable())) return false;
  const result = await llvls.ads.rewarded();
  return result.granted;
}
void requestExtraLife;

Call after init, at a real break and only after a deliberate player choice. The caller grants the reward only when the function returns true and handles rejected promises. Recheck availability close to the action and prevent duplicate requests while one is pending.

Offer a free way to continue, such as restarting, when the reward is unavailable or declined. Do not award the reward because an ad started, the request resolved or the game received resume.

Test both paths

Use the SDK panel’s simulated ad controls, including skip and completion, then check pause/mute handling. No simulation result establishes production availability or revenue.