Skip to main content

Installation

 npm install react-native-admob-native-ads --save 

Install react-native-vector-icons to use StarRatingView.

npm install react-native-vector-icons --save

Complete setup of react-native-vector-icons for iOS & Android.

Expo Setup​

Add your AdMob App IDs to app.json or app.config.js.

{
"expo": {
"plugins": [
[
"react-native-admob-native-ads",
{
"androidAppId": "ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy",
"iosAppId": "ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy",
"facebookMediation": false
}
]
]
}
}

Run expo prebuild to setup android & ios folders for local development.

caution

Expo Go is not supported.

Android Setup​

Add your AdMob App ID to AndroidManifest.xml, as described in the Google Mobile Ads SDK documentation.

<manifest>
<application>
<!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
</application>
</manifest>

iOS Setup​

Follow the guide to add Google Mobile Ads SDK to your Xcode project.

  1. In your Podfile:
pod 'Google-Mobile-Ads-SDK', '~>9.11.0'
  1. Update your info.plist file as mentioned in Admob Documentation

After configuring your project run:

pod install --repo-update

Requesting IDFA on iOS 14​

On iOS 14 onwards, you need to request IDFA access through App Tracking Transparency Dialog to show targeted ads to the user. For that you can use react-native-tracking-transparency.

Generate your Native Ad Ids​

Before you can show any ads, you will need to generate Admob Ids on your Admob account. For debugging you can use test ad ids provided by google given below:

Android​

TypeID
Native Advancedca-app-pub-3940256099942544/2247696110
Native Advanced Videoca-app-pub-3940256099942544/1044960115

iOS​

TypeID
Native Advancedca-app-pub-3940256099942544/3986624511
Native Advanced Videoca-app-pub-3940256099942544/2521693316

Enable Test Device​

A test device can be registered on App launch with AdManager:

import {AdManager} from "react-native-admob-native-ads";

AdManager.setRequestConfiguration({
testDeviceIds:["Your test device id"];
});

To get your device test ids, follow the guide for iOS & Android.

caution

When you newly generate your ad ids from Admob account and implement them in the app. It can take a few hours to a day for ads to show up. So be patient or use the test ids above for testing.