Test device ids that silently did nothing in a Release build
The config was present, awaited, and it resolved without error. testDeviceIdentifiers had one entry: "EMULATOR". On a simulator that works. On the physical phone used for QA, running a TestFlight build where __DEV__ === false, it protects nothing, and every request that device makes is a live request.
It did not surface as an exception. It surfaced as arithmetic: 10 clicks on 5 impressions in one day for a single app. Ten clicks from five impressions is not user behaviour, it is one person tapping the same ad. Over 14 days across the portfolio: 12 clicks on 33 impressions, 36.4% CTR, on roughly nine installs a week. That is invalid traffic by definition, generated on hardware we control, and it cost a publisher account a 29-day suspension.
Why __DEV__ is not the safety net it looks like
Ad unit selection in every app gated on __DEV__:
export const ADMOB_BANNER_AD_UNIT_ID = __DEV__ || AD_TEST_IDS
? TestIds.BANNER
: Platform.OS === "ios"
? ADMOB_BANNER_AD_UNIT_ID_IOS
: ADMOB_BANNER_AD_UNIT_ID_ANDROID;
Correct for a debug build, backwards for a Release build. The artifact that reaches a human is the unprotected one:
expo start—__DEV__true → sample units → safe- TestFlight, Play internal track, local archive —
__DEV__false → real units → live
Three things keep it quiet.
setRequestConfigurationresolves whether or not the running device matches anything on the list. An unlisted device is not a warning, it is a live ad request.- The only notice is the SDK's own log line, printing the device identifier and asking you to add it. It reads like ad noise and gets scrolled past.
- Nothing fails on the simulator, the one device always covered.
The one-line check
grep -rn "testDeviceIdentifiers" --include=*.ts --include=*.tsx .
If the answer is a literal array containing only "EMULATOR", every phone you own is a live device in every Release build. Two of five apps returned nothing at all — no setRequestConfiguration call anywhere, so the SDK ran on defaults nobody chose.
Check the binary next, because a fix that never reached the archive is the same as no fix. The environment value is inlined at build time, so a working allowlist appears as a literal:
APP=build/YourApp.xcarchive/Products/Applications/YourApp.app
grep -c "ABCD1234" "$APP/main.jsbundle" # first 8 chars of the id the build log printed
Zero means the id is not in the build you are about to upload.
The fix: move the ids out of source
// constants/admob.ts
const ENV_TEST_DEVICES = (process.env.EXPO_PUBLIC_TEST_DEVICE_IDS ?? "")
.split(",")
.map((id) => id.trim())
.filter(Boolean);
export const TEST_DEVICE_IDS: string[] = ["EMULATOR", ...ENV_TEST_DEVICES];
Pass it before initialize(), so no request can precede the configuration:
const ads = mobileAds();
await ads.setRequestConfiguration({ testDeviceIdentifiers: TEST_DEVICE_IDS });
await ads.initialize();
The build scripts do the join, so adding a QA phone is one line in one file and no code change:
IDS="$(grep -vE '^[[:space:]]*(#|$)' "$AD_TEST_DEVICES_FILE" | tr -d ' \r' | paste -sd, -)"
export EXPO_PUBLIC_TEST_DEVICE_IDS="${EXPO_PUBLIC_TEST_DEVICE_IDS:+$EXPO_PUBLIC_TEST_DEVICE_IDS,}$IDS"
Why not a force-test-ads flag
The first design was one switch: build with EXPO_PUBLIC_FORCE_TEST_ADS=1, serve sample units, verify, done. Wrong for a pipeline where a TestFlight artifact is promoted unchanged to the App Store — the flag rides along and production ships with no revenue at all. A device-scoped list is safe to bake into a shipping binary because it changes behaviour only for the ids on it.
Two layers exist and only one is durable: registering a device in the ad console stops working once the advertising identifier is unavailable — a denied ATT prompt is enough — while the in-app list is matched at request time. The console entry is documentation; the code is the control.
Make it a gate, not a habit
A static check across every app repo: development must resolve sample units, a Release path must carry a device list with something on it beyond "EMULATOR", and the list must come from the environment. Before the patch, zero of five passed. Now five of five do, and the next app added to the pipeline has to clear the same bar before upload.
Related: the ATT prompt that never appeared, ad frequency that survives App Review, and build gates that fail before upload.