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

    Function useAppOpenAdManager

    • App-open manager hook aligned with Google's AppOpenAdManager sample and app-open guidance.

      Behaviour:

      • Preloads via manual AppOpenAd.createForAdRequest + load() (cross-backend).
      • Treats inventory as invalid more than four hours after load (AdStalenessGuidanceMillis.APP_OPEN).
      • Auto-shows on warm foreground only, via useForeground (background → active). Does not auto-show on the very first cold start — call showAdIfAvailable() from your loading screen for that path.
      • On Android a foreground return caused by another library fullscreen ad Activity (interstitial / rewarded / app-open) dismissing does not trigger the warm-foreground auto-show, so two fullscreen ads never stack back-to-back. A real home / app-switcher return still shows. iOS does not background the app for these ads.
      • Guards with isShowing; reloads after CLOSED and show-phase errors while autoLoad is not false.

      While autoLoad is false, no path starts an ad request, so keep it false until consent is resolved; an ad already held can still show. Passing adUnitId: null (or not mounting the hook) is the strongest gate: it prevents every load and destroys any held ad.

      Every backend uses AppOpenAd.createForAdRequest. Android Next-Gen also exposes SDK-managed app-open preload (AppOpenAdPreloader / AdPools fullscreen app-open); composing this manager with that preloader is not yet supported and is not required for a correct manager.

      const { status, showAdIfAvailable, isShowing } = useAppOpenAdManager({
      adUnitId: TestIds.APP_OPEN,
      autoLoad: consentReady,
      });

      // Cold start loading screen (after the first launch, if you follow Google's
      // "don't show on the very first app start" guidance yourself). Offer once,
      // as soon as assets are ready, and never wait on consent: if consent is
      // unresolved, skip the offer and continue.
      const coldStartOffered = useRef(false);
      useEffect(() => {
      if (!assetsReady || coldStartOffered.current) {
      return;
      }
      coldStartOffered.current = true;
      if (consentReady) {
      showAdIfAvailable();
      }
      }, [assetsReady, consentReady, showAdIfAvailable]);
      // Hold a loading screen only for this cold-start pass. Keep the app tree
      // mounted while a warm-foreground ad shows.

      Parameters

      Returns UseAppOpenAdManagerResult