Skip to content

Getting Started

Overview

Capacitor community plugin for native AdMob. This plugin wraps the Google Mobile Ads SDK for iOS and Android so you can display banner, interstitial, rewarded, rewarded interstitial, and app open ads in Capacitor apps. It also covers Google User Messaging Platform (UMP) consent and App Tracking Transparency helpers on iOS.

Installation

This plugin already ships Google Mobile Ads SDK. Install the package, then add your AdMob application ID in AndroidManifest / Info.plist. Google's Get started guides for Android and iOS explain app IDs and SKAdNetwork identifiers (Apple's ad conversion IDs); do not add a second Mobile Ads dependency.

This plugin targets @capacitor-community/admob v8 and Capacitor 8. It supports iOS 15 or later and Android API 24 or later.

npm install @capacitor-community/admob
npx cap sync

If you still use Capacitor 7, install @capacitor-community/admob@7.

Google Mobile Ads SDK versions

This major version pins Google Mobile Ads SDK 25.4.x on Android and 13.6.0 on iOS (Swift Package Manager and CocoaPods). Leave those versions unless you have a specific need. Google's Next-Gen SDK for Android waits until the next plugin major. See Migration for the policy behind the pins.

Android configuration

In android/app/src/main/AndroidManifest.xml, add the following under <application>:

<meta-data
  android:name="com.google.android.gms.ads.APPLICATION_ID"
  android:value="@string/admob_app_id" />

In android/app/src/main/res/values/strings.xml:

<string name="admob_app_id">[APP_ID]</string>

Replace [APP_ID] with your AdMob application ID, not an ad unit ID.

Variables

You can leave these unset. Override them in your app's variables.gradle only when you need a specific artifact version:

Variable Artifact Default
playServicesAdsVersion com.google.android.gms:play-services-ads 25.4.+
userMessagingPlatformVersion com.google.android.ump:user-messaging-platform 4.0.0
androidxCoreKTXVersion androidx.core:core-ktx 1.15.0

iOS configuration

Add the following inside the outermost <dict> in ios/App/App/Info.plist:

<key>GADIsAdManagerApp</key>
<true/>
<key>GADApplicationIdentifier</key>
<string>[APP_ID]</string>
<key>SKAdNetworkItems</key>
<array>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>cstr6suwn9.skadnetwork</string>
  </dict>
</array>
<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>

Replace [APP_ID] with your AdMob application ID, and describe your actual tracking use in NSUserTrackingUsageDescription.

The SKAdNetworkItems snippet includes Google's own identifier. Add the other IDs from Google's iOS setup guide.

Troubleshooting

If CocoaPods cannot resolve Google-Mobile-Ads-SDK:

[error] Error running update: Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "Google-Mobile-Ads-SDK":

Run pod repo update in ios/, then npx cap sync ios again.

First test banner

After installation and platform setup, initialize the SDK, request consent, and show a Google demo banner. Use the platform banner IDs from Testing—do not create your own ad unit for this first check.

Call startAdMob from a user action or after the UI is ready (for example a button or post-navigation hook), not only at module evaluation time.

import { Capacitor } from '@capacitor/core';
import { AdMob, AdmobConsentStatus, BannerAdOptions, BannerAdSize, BannerAdPosition } from '@capacitor-community/admob';

const bannerAdId =
  Capacitor.getPlatform() === 'ios'
    ? 'ca-app-pub-3940256099942544/2934735716'
    : 'ca-app-pub-3940256099942544/6300978111';

async function startAdMob() {
  await AdMob.initialize();

  let consentInfo = await AdMob.requestConsentInfo();
  if (consentInfo.isConsentFormAvailable && consentInfo.status === AdmobConsentStatus.REQUIRED) {
    consentInfo = await AdMob.showConsentForm();
  }

  if (!consentInfo.canRequestAds) {
    // Consent not ready — no banner is shown.
    return;
  }

  const options: BannerAdOptions = {
    adId: bannerAdId,
    adSize: BannerAdSize.ADAPTIVE_BANNER,
    position: BannerAdPosition.BOTTOM_CENTER,
    margin: 0,
  };
  await AdMob.showBanner(options);
}

Expected result: when canRequestAds is true, a Google test banner appears at the bottom of the native screen. When canRequestAds is false, the function returns and no banner is shown. The banner sits above the WebView and can cover HTML—see Banner Ads to inset your layout. Details: Configuration, Consent, and Testing.

Choose by advertising goal

Goal Ad format Guide
Keep an ad visible alongside app content Banner Banner Ads
Show a full-screen ad at a natural break without granting a reward Interstitial Interstitial Ads
Offer a dedicated rewarded experience Rewarded Rewarded Ads
Offer a reward at a natural transition Rewarded interstitial Rewarded Ads
Monetize an app-open experience App Open App Open Ads

Documentation

Start with Installation above, then Configuration and Consent. Run the first test banner, then use Testing for demo units and devices. Pick an ad format from the table above. The same guides are also on the documentation site (English and Japanese). If you opened this README on npm, use that site for the guides — the docs/ files live in the GitHub repository. Method signatures are in the API section below.

  • ConfigurationAdMob.initialize and SDK options.
  • Consent — privacy consent and iOS tracking authorization.
  • Testing — demo ad units, test devices, and consent testing.
  • Banner Ads — banner options, lifecycle, and events.
  • Full-screen ads:
    • Interstitial Ads — load, show, and multiple prepared ads.
    • Rewarded Ads — rewarded video, rewarded interstitial, and server-side verification.
  • App Open Ads — load and present on foreground transitions.
  • Ad Events — shared lifecycle events, errors, and revenue data.
  • Migration Guide — historical notes when upgrading from older plugin versions.