Skip to main content

Example app

example/ is a NitroUI app that shows each ad format with Google's test ad units. It also holds the native harness tests.

Run it​

From the repo root:

bun install
cd example
bun run nitro-ui prepare
bun run ios --device <simulator-UDID>
bun run android --device <adb-serial>

What it shows​

example/src/App.tsx:

FeatureHow
Request configurationAdmob.setRequestConfiguration({ maxAdContentRating: 'general' }), then Admob.initialize().
Interstitial and rewardedTwo AdPreloaders, shown from buttons with take().
Rewarded interstitialLoaded on tap with keywords and server-side verification options.
App open adsstartAppOpenAds; background and reopen the app to see one.
BannersAn adaptive banner and a mediumRectangle.

Your own AdMob IDs​

Copy example/.env.example to example/.env and replace the values. The defaults are Google's sample IDs.

VariablesUsed for
ADMOB_IOS_APP_ID, ADMOB_ANDROID_APP_IDThe native app IDs in Info.plist and AndroidManifest.xml.
ADMOB_IOS_*_ID, ADMOB_ANDROID_*_IDAd unit IDs per format, compiled into the JS bundle.

Write plain KEY=value lines without quotes: Xcode reads the file as an xcconfig. scripts/env.ts writes src/env.ts from .env before every bundle; a variable set in the shell wins over .env, and a format without an ID falls back to Admob.testAdUnitId.

Harness tests​

example/__tests__ holds nitro-ui-harness tests that run inside the app against the native module: sample ad unit IDs, SDK start, and fixed and adaptive banner sizes.

bun run test:ios --device "<simulator name or UDID>"
bun run test:android --device <adb-serial>