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.
Consent
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.
Inventory source
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.
// 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. constcoldStartOffered = 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.
App-open manager hook aligned with Google's
AppOpenAdManagersample and app-open guidance.Behaviour:
AppOpenAd.createForAdRequest+load()(cross-backend).AdStalenessGuidanceMillis.APP_OPEN).showAdIfAvailable()from your loading screen for that path.isShowing; reloads afterCLOSEDand show-phase errors whileautoLoadis notfalse.Consent
While
autoLoadisfalse, no path starts an ad request, so keep itfalseuntil consent is resolved; an ad already held can still show. PassingadUnitId: null(or not mounting the hook) is the strongest gate: it prevents every load and destroys any held ad.Inventory source
Every backend uses
AppOpenAd.createForAdRequest. Android Next-Gen also exposes SDK-managed app-open preload (AppOpenAdPreloader/AdPoolsfullscreen app-open); composing this manager with that preloader is not yet supported and is not required for a correct manager.Example