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

    Type Alias AdPoolsApi

    type AdPoolsApi = {
        create(config: AdPoolConfig): Promise<AdPool>;
        destroyAll(): void;
        get(poolId: string): AdPool | null;
        getCapabilities(): AdCapabilities;
    }
    Index
    • Async because resolved is only knowable after native answers: buffer clamping depends on app-wide pool accounting, and validation consults live backend capabilities. Hard-errors on an impossible config; loud-degrades when a milder adjustment is safe.

      Hard-errors include rewarded interstitial pooling on both Android backends (classic and Next-Gen): neither Android SDK has a usable rewarded interstitial preloader, so the pool could never fill. Check fullscreenPreloadFormats before creating, or catch reason 'pool/format-preload-unsupported'.

      Parameters

      Returns Promise<AdPool>

      WARNING: Triggers Android native initialize() via ensureMobileAdsInitialized(). Do not call before consent is resolved. Prefer AdPoolProvider enabled (mirrors hook autoLoad), or only call after UMP / consent has finished.

      const pool = await AdPools.create(
      AdPoolPresets.fullscreen(AdFormat.INTERSTITIAL, TestIds.INTERSTITIAL),
      );
      const result = await pool.poll();
      if (result.status === 'filled') {
      const ad = result.ad;
      if (!ad.isStaleByPolicy() && ad.format === AdFormat.INTERSTITIAL) {
      // show() resolves once presentation starts; destroy on CLOSED.
      const offClosed = ad.addAdEventListener(AdEventType.CLOSED, () => {
      offClosed();
      ad.destroy();
      });
      // Rejects on decline; a destroyed ad would throw synchronously instead.
      await ad.show().catch(error => {
      offClosed();
      ad.destroy();
      console.warn(error);
      });
      } else {
      ad.destroy();
      }
      }
      // Destroy the pool when the placement is gone, not while its ad is on screen.