Use this if your app does not use Expo. Your React Native CLI project is already a native iOS and Android app, so there is no config plugin and no prebuild step.
The library autolinks. Put the AdMob app IDs in the root app.json, using snake_case. Do not paste IDs into Info.plist or AndroidManifest.xml, and do not edit AppDelegate or MainApplication for a standard install.
If your app uses Expo, follow Install with Expo.
Install the package
bashnpm install react-native-google-mobile-adsConfigure your app IDs
Before you display ads, create a Google AdMob account and an app ID for each platform. Google AdMob shows where the app ID appears in AdMob.
Add the IDs under the top-level
react-native-google-mobile-adskey in the project-rootapp.json, using snake_case. Autolinking and the Android Gradle and iOS config scripts apply these values during the native build. Edit this JSON, then rebuild. Do not keep a second copy in the native project files.json// <project-root>/app.json { "react-native-google-mobile-ads": { "android_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx", "ios_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx" } }WarningIf
android_app_idorios_app_idis missing from that block, native build scripts warn and the Google Mobile Ads software development kit (SDK) can crash on startup. An Expo app that sets IDs only on the config plugin can ignore that warning. Install with Expo covers that path.The Config plugin page lists every key, including the Expo camelCase names.
Rebuild the app
bash# For iOS npx pod-install npx react-native run-ios # For Android npx react-native run-android
This module is a CocoaPods pod only. There is no Swift Package Manager (SPM) Package.swift distribution yet. Until an SPM package exists, integrate the module through CocoaPods. Expo prebuild and Continuous Native Generation still resolve native modules through CocoaPods.
By default the podspec sets static_framework to false. Under CocoaPods use_frameworks!, the module uses dynamic linkage unless you opt into static frameworks in the next section. That default matches use_frameworks! :linkage => :dynamic. It does not replace a future SPM package for apps that consume React Native Firebase, or other dependencies, through SPM only.
This module does not require static frameworks for a normal bare install. Use them only when another dependency needs use_frameworks! :linkage => :static in your Podfile, for a need unrelated to React Native Firebase.
React Native Firebase coexistence is on the React Native Firebase page. Use that page's dynamic Podfile and static ads pod. Do not switch the whole Podfile to static frameworks as a substitute.
On a bare app, when you enable static frameworks, set $RNGoogleMobileAdsAsStaticFramework = true in the Podfile before any target block, use_native_modules!, or use_react_native!. Then run pod install again. Expo sets the same flag with expo-build-properties on Install with Expo.
$RNGoogleMobileAdsAsStaticFramework = trueThe Google Mobile Ads SDK supports conversion tracking with Apple's SKAdNetwork. Google and participating third-party buyers can attribute an app install when the Identifier for Advertisers (IDFA) is unavailable. Add the advised SKAdNetwork identifiers to your project. These identifiers change, so update them on a regular schedule.
// <project-root>/app.json
{
"react-native-google-mobile-ads": {
"android_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
"ios_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
"sk_ad_network_items": [
"cstr6suwn9.skadnetwork",
"4fzdc2evr5.skadnetwork",
"2fnua5tdw4.skadnetwork",
"ydx93a7ass.skadnetwork",
"p78axxw29g.skadnetwork",
"v72qych5uu.skadnetwork",
"ludvb6z3bs.skadnetwork",
"cp8zw746q7.skadnetwork",
"3sh42y64q3.skadnetwork",
"c6k4g5qg8m.skadnetwork",
"s39g8k73mm.skadnetwork",
"wg4vff78zm.skadnetwork",
"3qy4746246.skadnetwork",
"f38h382jlk.skadnetwork",
"hs6bdukanm.skadnetwork",
"mlmmfzh3r3.skadnetwork",
"v4nxqhlyqp.skadnetwork",
"wzmmz9fp6w.skadnetwork",
"su67r6k2v3.skadnetwork",
"yclnxrl5pm.skadnetwork",
"t38b2kh725.skadnetwork",
"7ug5zh24hu.skadnetwork",
"gta9lk7p23.skadnetwork",
"vutu7akeur.skadnetwork",
"y5ghdn5j9k.skadnetwork",
"v9wttpbfk9.skadnetwork",
"n38lu8286q.skadnetwork",
"47vhws6wlr.skadnetwork",
"kbd757ywx3.skadnetwork",
"9t245vhmpl.skadnetwork",
"a2p9lx4jpn.skadnetwork",
"22mmun2rn5.skadnetwork",
"44jx6755aq.skadnetwork",
"k674qkevps.skadnetwork",
"4468km3ulz.skadnetwork",
"2u9pt9hc89.skadnetwork",
"8s468mfl3y.skadnetwork",
"klf5c3l5u5.skadnetwork",
"ppxm28t8ap.skadnetwork",
"kbmxgpxpgc.skadnetwork",
"uw77j35x4d.skadnetwork",
"578prtvx9j.skadnetwork",
"4dzt52r2t5.skadnetwork",
"tl55sbb4fm.skadnetwork",
"c3frkrj4fj.skadnetwork",
"e5fvkxwrpn.skadnetwork",
"8c4e2ghe7u.skadnetwork",
"3rd42ekr43.skadnetwork",
"97r2b46745.skadnetwork",
"3qcr597p9d.skadnetwork"
]
}
}Apple requires the app to show the App Tracking Transparency authorization request before it reads the Identifier for Advertisers. The person using the app chooses personalized or non-personalized ads. In the project configuration file, set a user tracking usage description:
// <project-root>/app.json
{
"react-native-google-mobile-ads": {
"android_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
"ios_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
"user_tracking_usage_description": "This identifier will be used to deliver personalized ads to you."
}
}Request authorization at runtime on the Consent and privacy page.
CocoaPods installs an Xcode build phase named [RNGoogleMobileAds] Configuration. That phase writes GADApplicationIdentifier into the built app Info.plist from app.json.
If a release build fails with unable to locate Info.plist, upgrade this package and run pod install again so the embedded ios_config.sh polls briefly for $(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH) before it fails. Xcode can start the phase before Process Info.plist finishes writing that file. Phase timing metadata alone is not enough. Do not move that script earlier in Build Phases. An Expo app that uses the config plugin sets the app ID at prebuild and does not use this build phase.