Skip to content

ads

filudi.com has no ad network today: both ad kinds answer unavailable with reason host there. On CrazyGames, Poki and Playgama the SDK maps them to the portal’s own ads. Write the game so that every result is handled, and nothing depends on an ad showing.

Grant the reward on status === 'completed' and on nothing else. skipped, unavailable and error give nothing: a game that rewards an unavailable ad gives free rewards on every host that has none.

A rewarded ad

lifeButton.addEventListener('click', async () => {
lifeButton.hidden = true;
const result = await sdk.ads.rewarded();
if (result.status === 'completed') grantSecondLife();
});

At a natural break, after gameplay.stop(): a game over, a level end. The SDK refuses it with too-soon inside the host’s minimum interval, 120 s on filudi.com and on the mock, counted from the end of the last ad shown of either kind. Portals pace their own interstitials. The result is informative; most games ignore it.

An interstitial at game over

async function gameOver() {
sdk.gameplay.stop();
overs += 1;
if (overs % 3 === 0) await sdk.ads.interstitial();
showGameOver();
}

AdResult

const result = await sdk.ads.rewarded();
switch (result.status) {
case 'completed': // rewarded: grant the reward
case 'skipped': // the player closed it early
case 'unavailable': // result.reason: 'no-fill' | 'adblock' | 'host' | 'policy' | 'busy' | 'too-soon'
case 'error': // result.message
}
  • One ad at a time. A second call while one runs returns unavailable with reason busy.
  • Before an ad the SDK calls gameplay.stop() and fires the start event; after it, the end event, then gameplay.start() if play was running. The game does not bracket ads itself.
  • Without ad consent the filudi host answers unavailable with reason policy.
  • No answer from the host within 90 s is { status: 'error', message: 'host timeout' }.

type is 'start' or 'end'. Mute audio on start, not when you request the ad: a refused ad never starts, and the game would stay silent. The listener takes no argument. The call returns a function that removes the listener.

Mute during an ad

sdk.ads.on('start', () => audio.mute());
sdk.ads.on('end', () => audio.unmute());

ads.available(): { rewarded: boolean; interstitial: boolean }

Section titled “ads.available(): { rewarded: boolean; interstitial: boolean }”

Whether a “watch an ad” button is worth drawing. It can change after init() (adblock detection): read it each time you draw the button, not once. Throws before init() resolves.

Draw the button only when an ad can show

function showGameOver() {
lifeButton.hidden = usedLife || !sdk.ads.available().rewarded;
}
ReasonWhen
hostThe host has no ads: filudi.com today, the standalone mock, a portal in a disabled environment
no-fillThe portal had no ad to show
adblockThe portal detected an ad blocker; available() turns both kinds off
policyNo ad consent, or the site’s age policy forbids ads
busyAnother ad is running
too-soonAn interstitial inside the host’s minimum interval

Where to put ads in a game, and what filudi.com offers, is in ads on portals.