Skip to main content

startAppOpenAds

import { startAppOpenAds, type AppOpenAdsOptions } from 'nitro-ui-admob'
function startAppOpenAds(options: AppOpenAdsOptions): () => void

Shows an app open ad each time the app returns from the background, following Google's guidance: the ad is preloaded and replaced before it expires, nothing shows on a cold start or over another full-screen ad, and minimumInterval caps how often ads show.

Returns a function that stops showing and loading app open ads. Guide: app open ads.

AppOpenAdsOptions​

FieldTypeDescription
adUnitIdstringRequired. The AdMob app open ad unit ID.
requestOptionsAdmobRequestOptionsTargeting for the ad requests.
minimumIntervalnumberThe minimum time between two app open ads, in milliseconds. Defaults to 0.
onWillShow(ad: AppOpenAd) => voidCalled with each ad right before it is shown, for example to set its callbacks.
onLoadError(error: unknown) => voidCalled with each failed load. Loads are retried with backoff.
const stop = startAppOpenAds({
adUnitId: Admob.testAdUnitId('appOpen'),
minimumInterval: 30 * 60 * 1000,
})