Admob (Google Ads) Settings

Note : Please use latest version of source code.

  1. Go to https://apps.admob.com/ and signup with your existing gmail if you don’t have admob account already.
  2. Now from the left menu click on Apps > ADD APP
  3. Now select platform (Android/iOS) . Create separate apps for Android and iOS.
  1. Select no if your app is not on the app store or play store and Press ADD APP. After you publish your app to play store or app store once, come back here and add your app information here.
  2. If your app is already in any of the stores, select Yes, the app is listed on a supported app store, and in the next step enter your package / bundle identifier and click search. Your app will be shown in the list. Click ADD button next to your app. And finally, click ADD APP button.
  3. Now from the left menu click Ad units > Get Started > Banner
Click on Select
  1. Now type your ad unit name and press Create ad unit and press Done.
  2. From the left menu click on Ad units and click on your ad unit name you’ll see something like the following image
  1. Now click Implementation instructions and you’ll see like the following image
Step : 8
  1. Copy the app ID which is beside mark A (ca-app-pub-6377007785042974~8598264183)
  2. Open app.json paste the appID in react-native-google-mobile-ads>android_app_id for android and for iOS in react-native-google-mobile-ads>ios_app_id.
    This is outside expo object
  1. Now copy the ad unit ID beside B marking from step 8
  2. Open App>services > adMobConfig.js . Paste the ad unit ID in admobConfig > admobBannerId > android or admobConfig > admobBannerId > ios .

  3. Now set the value of admobConfig > admobEnabled to true.
  4. Now run command “npx expo install react-native-google-mobile-ads ” and “npx expo install expo-tracking-transparency
    npx expo install react-native-google-mobile-ads
    npx expo install expo-tracking-transparency
  5. Open navigation > HomeNavigator.jsx file and remove ‘//’ from line number 1, 2, 3, 4. (See image below). And also from line 83 to 98 and 101 to 103.


Open components > AdmobBanner.jsx and remove “//” from line 1. (See image below)

And finally in App.js file remove “//” from the following lines:

16. Now add the below marked lines. This is required for appstore privacy policy. If you do not provide this, your app will be rejected.

[

“expo-tracking-transparency”,

{

“userTrackingPermission”: “Classima wants to track you to collect IDFA to deliver personalised ads.”

}

],

17. Insert “com.google.android.gms.permission.AD_ID” in app.json file expo . android > permissions array.



– After configuring Admob, please create a new build and test with that. Older build will produce errors.

18. Finally follow these for tracking privacy settings in appstore while submitting your app for review . If you do not configure this properly, appstore will reject your submission.
Also follow these for play store submission.

19. Common issue: After setting everything if you get any error from AdMob, Please check the error codes here

You can enable or disable banners in different pages from the following configuration file
app > services > admobConfig.js
– You just need to put true to enable admob in a specific screen or false to disable them.