Skip to content

InterstitialAd ​

Full-screen ad that displays at natural transition points -- between sessions, after a conversation ends, or at a message threshold. Users play a sponsored mini-game with an AI character.

Interstitial ad displayed full-screen on mobile

Basic Usage (Imperative) ​

jsx
import { useEffect, useRef, useState } from 'react';
import { SimulaInterstitialAd, SimulaAdEventType } from '@simula/ads-react-native';

function ChatScreen() {
  const [loaded, setLoaded] = useState(false);
  const retryAttempt = useRef(0);
  const interstitial = useRef(null);

  useEffect(() => {
    interstitial.current = SimulaInterstitialAd.create('SIM-INT-XXXXXXXX');

    const subs = [
      interstitial.current.addAdEventListener(SimulaAdEventType.LOADED, () => {
        retryAttempt.current = 0;
        setLoaded(true);
      }),
      interstitial.current.addAdEventListener(SimulaAdEventType.LOAD_FAILED, () => {
        retryAttempt.current += 1;
        if (retryAttempt.current > 6) return;
        const delay = Math.pow(2, retryAttempt.current);
        setTimeout(() => interstitial.current.load(), delay * 1000);
      }),
      interstitial.current.addAdEventListener(SimulaAdEventType.CLOSED, () => {
        setLoaded(false);
        // Next ad auto-preloads, but you can also manually reload
      }),
    ];

    interstitial.current.load({
      charId: 'reze-01',
      charName: 'Reze',
      charImage: 'https://cdn.example.com/avatars/reze.png',
    });

    return () => {
      subs.forEach((unsub) => unsub());
      interstitial.current.destroy();
    };
  }, []);

  const handleShow = () => {
    if (loaded) interstitial.current.show();
  };

  return <ChatInterface onTransition={handleShow} />;
}

Basic Usage (Hook) ​

The useInterstitialAd hook manages the ad lifecycle automatically:

jsx
import { useEffect } from 'react';
import { useInterstitialAd } from '@simula/ads-react-native';

function ChatScreen() {
  const { isLoaded, isClosed, error, load, show } = useInterstitialAd('SIM-INT-XXXXXXXX');

  useEffect(() => {
    load({ charId: 'reze-01', charName: 'Reze' });
  }, [load]);

  return (
    <Button title="Show Ad" disabled={!isLoaded} onPress={show} />
  );
}

Hook Return Values ​

FieldTypeDescription
isLoadedbooleanAd is ready to show()
isClosedbooleanAd was just dismissed by the user
errorSimulaAdError | undefinedLast error from load or show
load(options?) => voidLoad an ad with optional character context
show() => voidPresent the loaded ad
setMetadata(key, value) => void | (metadata) => voidAttach reporting labels. See Metadata

AI Character Integration ​

Pass your app's character data so the character plays alongside the user in the ad playable experience. The character commentates, competes, and engages with the user during gameplay — improving the ad experience and raising payout. Omit to use a Simula default character.

Character context drives engagement

Passing character context lets the AI companion in the mini-game match your app's character — using their name, avatar, and personality. Users see a familiar face instead of a generic character, which increases play time and ad revenue.

ParameterTypeRequiredDescription
charIdstringNoCharacter identifier
charNamestringNoCharacter name displayed in game header
charImagestringNoCharacter avatar URL
charDescstringNoCharacter description for AI context

Metadata ​

Attach up to 10 key/value labels to segment your reporting. Set them before load() — same on the imperative API and the hook:

jsx
interstitial.current.setMetadata('screen', 'chat');                    // upsert one key
interstitial.current.setMetadata({ screen: 'chat', tier: 'free' });    // replace all

Keys: ≤64 chars, no $ prefix, no .. Values: ≤256 chars. Extra or invalid entries are dropped.

Event Types ​

EventDescription
SimulaAdEventType.LOADEDAd loaded and ready to show
SimulaAdEventType.LOAD_FAILEDAd failed to load. Retry with exponential backoff
SimulaAdEventType.DISPLAYEDAd displayed on screen
SimulaAdEventType.IMPRESSIONImpression recorded (server impression beacon fired)
SimulaAdEventType.DISPLAY_FAILEDAd failed to display. Load a new ad
SimulaAdEventType.CLICKEDUser tapped the CTA
SimulaAdEventType.PAIDEstimated per-impression revenue available. event.adValue contains the AdValue
SimulaAdEventType.CLOSEDUser dismissed the ad. Next ad auto-preloads

Listening to All Events ​

Use addAdEventsListener to subscribe to every event on an ad instance with a single listener. Useful for analytics or debug logging:

jsx
interstitial.current.addAdEventsListener((event) => {
  analytics.track('ad_event', { type: event.type, adUnit: 'SIM-INT-XXXXXXXX' });
});

Lifecycle ​

  • Auto-preload on close: The SDK automatically preloads the next ad when the user dismisses the current one.
  • 1-hour expiry: A loaded ad expires after 1 hour. show() fails with stale -- call load() again.
  • Deduplication: Calling load() with the same parameters within 5 minutes returns duplicate_request. Wait for the retry window or change the character context.
  • Cleanup: Always call destroy() when using the imperative API. The hook handles cleanup automatically.