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
| Feature | How |
|---|---|
| Request configuration | Admob.setRequestConfiguration({ maxAdContentRating: 'general' }), then Admob.initialize(). |
| Interstitial and rewarded | Two AdPreloaders, shown from buttons with take(). |
| Rewarded interstitial | Loaded on tap with keywords and server-side verification options. |
| App open ads | startAppOpenAds; background and reopen the app to see one. |
| Banners | An 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.
| Variables | Used for |
|---|---|
ADMOB_IOS_APP_ID, ADMOB_ANDROID_APP_ID | The native app IDs in Info.plist and AndroidManifest.xml. |
ADMOB_IOS_*_ID, ADMOB_ANDROID_*_ID | Ad 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>