Google AdMob

Create the AdMob app, copy the App ID, and set ad request options before you initialize.

Create the AdMob app, copy each platform's App ID into this project, and set ad request options before you initialize the SDK.

  • Create the AdMob app

    You need a Google AdMob account. Under Apps, create or choose an Android app and an iOS app. Each platform has its own App ID.

  • Copy the App ID

    Under App settings, copy the App ID.

    AdMob App settings page with the App ID
    App ID on the AdMob App settings page.
  • Add the App ID to the project

    Put each App ID in one place. Do not also paste it into Info.plist or AndroidManifest.xml.

    • Expo: config plugin (androidAppId / iosAppId). See Install with Expo.
      • React Native CLI: root app.json snake_case (android_app_id / ios_app_id). See Install with React Native CLI. Missing keys warn at build time and can crash the SDK on startup.
  • Configure outbound requests

    Call setRequestConfiguration before mobileAds().initialize() when the defaults are wrong for the app. A child-directed app must limit requests to suitable content before any ad loads.

    js
    import mobileAds, { MaxAdContentRating } from 'react-native-google-mobile-ads';
    
    mobileAds()
      .setRequestConfiguration({
        // Update all future requests suitable for parental guidance
        maxAdContentRating: MaxAdContentRating.PG,
    
        // Indicates that you want your content treated as child-directed for purposes of COPPA.
        tagForChildDirectedTreatment: true,
    
        // Indicates that you want the ad request to be handled in a
        // manner suitable for users under the age of consent.
        tagForUnderAgeOfConsent: true,
    
        // Hashed ids of physical test devices; emulators and simulators are automatic.
        // See /testing#register-a-test-device.
        testDeviceIdentifiers: ['YOUR-HASHED-TEST-DEVICE-ID'],
      })
      .then(() => {
        // Request config successfully set!
      });

    The fields are in the RequestConfiguration source.

On this page