Pick this install when your app uses Expo. For this library, that is the recommended install. Expo reads the app config, and the config plugin writes the native iOS and Android projects at prebuild, including the AdMob app IDs.
This package contains native code, so Expo Go cannot run it. Use a development build, usually with expo-dev-client or Expo Application Services (EAS) Build.
If your app does not use Expo, follow Install with React Native CLI.
Install the package
bashnpx expo install react-native-google-mobile-adsConfigure your app IDs
Add the Expo config plugin to
app.json,app.config.js, orapp.config.ts. After you change it, rebuild native code and install the new build on your device. The steps are in Generate native projects.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.
json// <project-root>/app.json { "expo": { "plugins": [ [ "react-native-google-mobile-ads", { "androidAppId": "ca-app-pub-xxxxxxxx~xxxxxxxx", "iosAppId": "ca-app-pub-xxxxxxxx~xxxxxxxx" } ] ] } }Every plugin key is on the Config plugin page.
InformationPut Expo app IDs on the config plugin only. You do not also add a root-level
react-native-google-mobile-adsblock withios_app_idorandroid_app_id. The plugin writesGADApplicationIdentifierand the AndroidAPPLICATION_IDduring prebuild. A legacy build-script warning about a missing rootios_app_idorandroid_app_idcan still appear. Ignore that warning when the plugin already wrote the IDs.Add a development client
If you do not already have a development build workflow, install the Expo development client:
bashnpx expo install expo-dev-clientThen create a development build. Use EAS, or a local prebuild and a
run:*command, in the next step.Generate native projects
After you install the module or change the plugin config, generate the native projects, then build each platform:
bashnpx expo prebuild # iOS npx expo run:ios # Android npx expo run:androidIf you use EAS instead of a local
run:*command, create a new development build. EAS runs prebuild as part of the build:bashnpm install --global eas-cli # Online eas build --profile development # Local eas build --profile development --localRun prebuild again, or create a new EAS build, when you change app IDs or other plugin options.
The Google Mobile Ads software development kit (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
{
"expo": {
"plugins": [
[
"react-native-google-mobile-ads",
{
"androidAppId": "ca-app-pub-xxxxxxxx~xxxxxxxx",
"iosAppId": "ca-app-pub-xxxxxxxx~xxxxxxxx",
"skAdNetworkItems": [
"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
{
"expo": {
"plugins": [
[
"react-native-google-mobile-ads",
{
"androidAppId": "ca-app-pub-xxxxxxxx~xxxxxxxx",
"iosAppId": "ca-app-pub-xxxxxxxx~xxxxxxxx",
"userTrackingUsageDescription": "This identifier will be used to deliver personalized ads to you."
}
]
]
}
}Request authorization at runtime on the Consent and privacy page.
This module does not require static frameworks for a normal Expo install. Use them only when another dependency needs use_frameworks! :linkage => :static.
React Native Firebase coexistence is on the React Native Firebase page. Use that
page's dynamic Podfile and static ads pod. Do not use the static snippet on this page as the React
Native Firebase recipe. Static frameworks alone fail at pod install when React Native Firebase
uses its default Swift Package Manager (SPM) mode.
On Expo, enable fully static frameworks for the whole Podfile with expo-build-properties only when another dependency, unrelated to React Native Firebase, needs that mode. For React Native Firebase with SPM, you still set $RNGoogleMobileAdsAsStaticFramework = true in the generated Podfile, as the React Native Firebase page describes. If a resource-bundle pod fails on IPHONEOS_DEPLOYMENT_TARGET, follow iOS CocoaPods deployment targets. Merge the plugin entry from the expo-build-properties instructions:
// <project-root>/app.json
{
"expo": {
"plugins": [
[
"expo-build-properties",
{
"ios": {
"useFrameworks": "static"
}
}
]
]
}
}