Skip to content

Getting Started

  1. Install the plugin

    Terminal window
    npm i @capgo/capacitor-admob
  2. Sync native projects

    Terminal window
    npx cap sync
import { AdMob, MaxAdContentRating } from '@capgo/capacitor-admob';
import { Capacitor } from '@capacitor/core';
// Start the Mobile Ads SDK once in your application bootstrap
await AdMob.start();
// Optional: configure global request settings
await AdMob.configure({
appMuted: false,
appVolume: 1,
});
// iOS: request tracking authorization
const platform = Capacitor.getPlatform();
if (platform === 'ios') {
await AdMob.requestTrackingAuthorization();
}
await AdMob.configRequest({
maxAdContentRating: MaxAdContentRating.T,
tagForChildDirectedTreatment: false,
tagForUnderAgeOfConsent: false,
});

android/app/src/main/AndroidManifest.xml

<application>
...
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-000000000000000~0000000000"/>
</application>

## iOS configuration

ios/App/App/Info.plist

<dict>
...
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-000000000000000~0000000000</string>
<key>NSUserTrackingUsageDescription</key>
<string>Your data will be used to deliver personalized ads and help us keep YourAppName free to play.</string>
</dict>
import { BannerAd } from '@capgo/capacitor-admob';
const banner = new BannerAd({
adUnitId: 'ca-app-pub-xxxxxxxxxxxxxxxx/banner',
position: 'bottom',
});
await banner.show();
import { InterstitialAd, RewardedAd } from '@capgo/capacitor-admob';
const interstitial = new InterstitialAd({
adUnitId: 'ca-app-pub-xxxxxxxxxxxxxxxx/interstitial',
});
await interstitial.load();
await interstitial.show();
const rewarded = new RewardedAd({
adUnitId: 'ca-app-pub-xxxxxxxxxxxxxxxx/rewarded',
});
await rewarded.load();
await rewarded.show();
import { AdMob } from '@capgo/capacitor-admob';
const handle = await AdMob.addListener('adImpression', (event) => {
console.log('Ad impression', event);
});
// Later when cleaning up
await handle.remove();
  • iOS: Add your AdMob app ID to Info.plist under the GADApplicationIdentifier key and include any SKAdNetwork IDs you rely on.
  • Android: Declare your AdMob app ID in AndroidManifest.xml by adding com.google.android.gms.ads.APPLICATION_ID inside the <application> tag.
  • Consent & Privacy: Use requestTrackingAuthorization() on iOS 14+ and configRequest() child-directed flags to stay compliant with regional privacy rules.
  • iOS: On npx cap sync got this error The 'Pods-App' target has transitive dependencies that include statically linked binaries: (Google-Mobile-Ads-SDK and GoogleUserMessagingPlatform) solved by editing ios/App/Podfile on line 4 adding use_frameworks! :linkage => :static