react-native-google-mobile-ads
    Preparing search index...

    Interface MobileAdAbstract

    interface MobileAd {
        _adDestroyFunction: AdDestroyFunction;
        _adEventListenerId: number;
        _adEventListenersMap: Map<
            EventType,
            Map<number, AdEventListener<EventType>>,
        >;
        _adEventsListenerId: number;
        _adEventsListeners: Map<number, AdEventsListener<EventType>>;
        _adLoadFunction: AdLoadFunction;
        _adShowFunction: AdShowFunction;
        _adUnitId: string;
        _destroyed: boolean;
        _isLoadCalled: boolean;
        _loaded: boolean;
        _nativeListener: EmitterSubscription;
        _presenceMarked: boolean;
        _requestId: number;
        _requestOptions: RequestOptions;
        _responseInfo: ResponseInfo | null;
        _showRequested: boolean;
        _type: AdType;
        get _className(): string;
        get adUnitId(): string;
        get loaded(): boolean;
        get responseInfo(): ResponseInfo | null;
        _addAdEventListener<T extends EventType>(
            type: T,
            listener: AdEventListener<T>,
        ): () => void;
        _addAdEventsListener<T extends EventType>(
            listener: AdEventsListener<T>,
        ): () => void;
        _getAdEventListeners<T extends EventType>(
            type: T,
        ): Map<number, AdEventListener<T>>;
        _handleAdEvent(
            event: {
                body: {
                    data?:
                        | RewardedAdReward & { responseInfo?: ResponseInfo }
                        | AppEvent & { responseInfo?: ResponseInfo }
                        | PaidEvent & { responseInfo?: ResponseInfo }
                        | { responseInfo?: ResponseInfo };
                    error?: {
                        code: string;
                        message: string;
                        phase?: "load" | "show";
                        reason?: string;
                        responseInfo?: ResponseInfo;
                        responseInfoJson?: string;
                    };
                    type: EventType;
                };
            },
        ): void;
        addAdEventListener<T extends never>(
            type: T,
            listener: AdEventListener<T>,
        ): void;
        addAdEventsListener<T extends never>(
            listener: AdEventsListener<T>,
        ): () => void;
        destroy(): void;
        load(): void;
        removeAllListeners(): void;
        show(showOptions?: AdShowOptions): Promise<void>;
    }

    Hierarchy (View Summary)

    Implements

    • MobileAdInterface
    Index
    • Parameters

      • event: {
            body: {
                data?:
                    | RewardedAdReward & { responseInfo?: ResponseInfo }
                    | AppEvent & { responseInfo?: ResponseInfo }
                    | PaidEvent & { responseInfo?: ResponseInfo }
                    | { responseInfo?: ResponseInfo };
                error?: {
                    code: string;
                    message: string;
                    phase?: "load" | "show";
                    reason?: string;
                    responseInfo?: ResponseInfo;
                    responseInfoJson?: string;
                };
                type: EventType;
            };
        }

      Returns void

    • Listen to ad events. See AdEventTypes for more information.

      Returns an unsubscriber function to stop listening to further events.

      // Create InterstitialAd/RewardedAd
      const advert = InterstitialAd.createForAdRequest('...');

      const unsubscribe = advert.addAdEventListener(AdEventType.LOADED, () => {

      });

      // Sometime later...
      unsubscribe();

      Type Parameters

      • T extends never

      Parameters

      • type: T

        The event type, e.g. AdEventType.LOADED.

      • listener: AdEventListener<T>

        A listener callback containing a event type, error and data.

      Returns void

    • Listen to ad events. See AdEventTypes for more information.

      Returns an unsubscriber function to stop listening to further events.

      // Create InterstitialAd/RewardedAd
      const advert = InterstitialAd.createForAdRequest('...');

      const unsubscribe = advert.addAdEventsListener(({ type, payload }) => {
      });

      // Sometime later...
      unsubscribe();

      Type Parameters

      • T extends never

      Parameters

      • listener: AdEventsListener<T>

        A listener callback containing a event type, error and data.

      Returns () => void

    • Release native resources for this ad instance. Idempotent; safe to call from React effect cleanup.

      Returns void

    • Start loading the advert with the provided RequestOptions.

      It is recommended you setup ad event handlers before calling this method.

      Returns void

    • Show the loaded advert to the user.

      Uses two error channels:

      • Rejects the returned promise when the show did not happen: the ad has not loaded, a show is already in flight, or the platform declines. Handle these with .catch() (or try { await } catch).
      • Throws synchronously for programmer errors: the ad has been destroyed, or showOptions are structurally invalid (checked only on a loaded ad with no show in flight, so otherwise the rejection comes first). Fix the call site.

      The fullscreen hooks' show absorbs both channels.

      // Create InterstitialAd/RewardedAd
      const advert = InterstitialAd.createForAdRequest('...');

      advert.addAdEventListener(AdEventType.LOADED, () => {
      advert
      .show({
      immersiveModeEnabled: true,
      })
      .catch(console.warn);
      });

      Parameters

      • OptionalshowOptions: AdShowOptions

        An optional AdShowOptions interface.

      Returns Promise<void>

    _adDestroyFunction: AdDestroyFunction
    _adEventListenerId: number
    _adEventListenersMap: Map<EventType, Map<number, AdEventListener<EventType>>>
    _adEventsListenerId: number
    _adEventsListeners: Map<number, AdEventsListener<EventType>>
    _adLoadFunction: AdLoadFunction
    _adShowFunction: AdShowFunction
    _adUnitId: string
    _destroyed: boolean
    _isLoadCalled: boolean
    _loaded: boolean
    _nativeListener: EmitterSubscription
    _presenceMarked: boolean
    _requestId: number
    _requestOptions: RequestOptions
    _responseInfo: ResponseInfo | null
    _showRequested: boolean
    _type: AdType