Skip to content

About

Capacitor plugin to bridge AdMob SDKs for iOS and Android

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

14 stars

Watchers

0 watching

Forks

@capgo/capacitor-admob

Show Google AdMob ads in your Capacitor app on iOS and Android: banner, interstitial, rewarded and rewarded interstitial formats from one TypeScript API. Monetize your app with the official Google Mobile Ads SDKs underneath.

Capgo - Instant updates for Capacitor

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

14-day unlimited free trial. No credit card required

Missing a feature? We'll build the plugin for you 💪

@capgo/capacitor-admob for Capacitor apps

Key features

  • Four ad formats: BannerAd, InterstitialAd, RewardedAd and RewardedInterstitialAd classes with load and show, plus hide() on BannerAd.
  • Ad lifecycle: adCreate(), adLoad(), adIsLoaded(), adShow() and adHide() give you full control over each ad instance.
  • SDK setup: start() initializes AdMob, configure() sets app-wide options and configRequest() sets request options.
  • App Tracking Transparency: trackingAuthorizationStatus() and requestTrackingAuthorization() handle the iOS tracking prompt.
  • Current SDKs: Google Mobile Ads Next Gen SDK on Android and Google Mobile Ads SDK on iOS.
  • Platforms: iOS and Android. The web implementation is a no-op stub.

AdMob SDK bridge for Capacitor apps

Android now uses the Google Mobile Ads Next Gen SDK, and iOS is aligned to Google Mobile Ads SDK 13.1.x, while preserving the existing Capacitor-facing API.

Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/admob/

Compatibility

Plugin version Capacitor compatibility Maintained
v8.*.* v8.*.* ✅
v7.*.* v7.*.* On demand
v6.*.* v6.*.* ❌
v5.*.* v5.*.* ❌

Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-admob` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capgo/capacitor-admob
npx cap sync

Consent (UMP)

For apps serving users in the EEA/UK, request consent with Google's User Messaging Platform (UMP) before loading ads. Configure GDPR messages in your AdMob account first.

import { AdMob, AdmobConsentStatus } from '@capgo/capacitor-admob';

await AdMob.start();

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

if (consentInfo.canRequestAds) {
  // Load ads only after consent allows ad requests.
}

To let users manage privacy choices later, call showPrivacyOptionsForm() from a settings screen when privacyOptionsRequirementStatus is REQUIRED.

For local testing on a real device, pass debugGeography and testDeviceIdentifiers to requestConsentInfo().

API

AdMob Plus Plugin interface for displaying Google AdMob ads in Capacitor apps.

start()

start() => Promise<void>

Initialize and start the AdMob SDK.

Since: 1.0.0


configure(...)

configure(config: AdMobConfig) => Promise<void>

Configure AdMob settings.

Param Type Description
config AdMobConfig - Configuration options for AdMob

Since: 1.0.0


configRequest(...)

configRequest(requestConfig: RequestConfig) => Promise<void>

Configure ad request settings.

Param Type Description
requestConfig RequestConfig - Request configuration options

Since: 1.0.0


requestConsentInfo(...)

requestConsentInfo(options?: AdmobConsentRequestOptions | undefined) => Promise<AdmobConsentInfo>

Request user consent information from Google's User Messaging Platform (UMP).

Call this after start() and before loading ads for users in the EEA/UK.

Param Type Description
options AdmobConsentRequestOptions - Optional consent request options for debugging and tagging

Returns: Promise<AdmobConsentInfo>

Since: 8.2.0


showConsentForm()

showConsentForm() => Promise<AdmobConsentInfo>

Shows the Google user consent form rendered from your GDPR message configuration.

Returns: Promise<AdmobConsentInfo>

Since: 8.2.0


showPrivacyOptionsForm()

showPrivacyOptionsForm() => Promise<void>

Shows the Google privacy options form rendered from your GDPR message configuration.

Use this when your privacy message requires an in-app entry point for users to manage choices.

Since: 8.2.0


adCreate(...)

adCreate<O extends MobileAdOptions>(opts: O) => Promise<void>

Create a new ad instance.

Param Type Description
opts O - Options for creating the ad, including ad unit ID

Since: 1.0.0


adIsLoaded(...)

adIsLoaded(opts: { id: number; }) => Promise<boolean>

Check if an ad is loaded and ready to be shown.

Param Type Description
opts { id: number; } - Object containing the ad ID

Returns: Promise<boolean>

Since: 1.0.0


adLoad(...)

adLoad(opts: { id: number; }) => Promise<void>

Load an ad.

Param Type Description
opts { id: number; } - Object containing the ad ID

Since: 1.0.0


adShow(...)

adShow(opts: { id: number; }) => Promise<void>

Show a loaded ad.

Param Type Description
opts { id: number; } - Object containing the ad ID

Since: 1.0.0


adHide(...)

adHide(opts: { id: number; }) => Promise<void>

Hide a currently displayed ad.

Param Type Description
opts { id: number; } - Object containing the ad ID

Since: 1.0.0


trackingAuthorizationStatus()

trackingAuthorizationStatus() => Promise<{ status: TrackingAuthorizationStatus | false; }>

Get the current tracking authorization status (iOS only).

Returns: Promise<{ status: false | TrackingAuthorizationStatus; }>

Since: 1.0.0


requestTrackingAuthorization()

requestTrackingAuthorization() => Promise<{ status: TrackingAuthorizationStatus | false; }>

Request tracking authorization from the user (iOS only).

Returns: Promise<{ status: false | TrackingAuthorizationStatus; }>

Since: 1.0.0


addListener(E, ...)

addListener<E extends AdMobPlusEventName>(eventName: E, listenerFunc: (event: AdMobPlusEventPayloadMap[E]) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Add a listener for ad events.

Param Type Description
eventName E - The name of the event to listen for
listenerFunc (event: AdMobPlusEventPayloadMap[E]) => void - The function to call when the event occurs

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 1.0.0


getPluginVersion()

getPluginVersion() => Promise<{ version: string; }>

Get the native Capacitor plugin version.

Returns: Promise<{ version: string; }>

Since: 1.0.0


Interfaces

PluginListenerHandle

Prop Type
remove () => Promise<void>

Type Aliases

AdMobConfig

Configuration options for AdMob.

{ /** Whether the app should be muted / appMuted?: boolean; /* The app volume (0.0 to 1.0) */ appVolume?: number; }

RequestConfig

Configuration for ad requests.

{ /** Maximum ad content rating / maxAdContentRating?: MaxAdContentRating; /* Whether to use the same app key / sameAppKey?: boolean; /* Tag for child-directed treatment (true, false, or null for unspecified) / tagForChildDirectedTreatment?: boolean | null; /* Tag for under age of consent (true, false, or null for unspecified) / tagForUnderAgeOfConsent?: boolean | null; /* Array of test device IDs */ testDeviceIds?: string[]; }

AdmobConsentInfo

Consent information returned by UMP.

{ /** The consent status of the user. / status: AdmobConsentStatus; /* If true, a consent form is available. / isConsentFormAvailable?: boolean; /* If true, an ad request can be made. / canRequestAds: boolean; /* Privacy options requirement status of the user. */ privacyOptionsRequirementStatus: PrivacyOptionsRequirementStatus; }

AdmobConsentRequestOptions

Options for requesting UMP consent information.

{ /** Sets the debug geography to test consent locally. / debugGeography?: AdmobConsentDebugGeography; /* * Test device IDs to allow for consent debugging. * On iOS, the ID may change if you uninstall and reinstall the app. / testDeviceIdentifiers?: string[]; /* * When true, tags the user as under the age of consent for UMP requests. * * @default false */ tagForUnderAgeOfConsent?: boolean; }

MobileAdOptions

Base options for mobile ads.

{ /** The ad unit ID from AdMob */ adUnitId: string; }

AdMobPlusEventName

(typeof AdMobPlusEvents)[keyof typeof AdMobPlusEvents]

AdMobPlusEventPayloadMap

Maps each {@link AdMobPlusEventName} to the payload shape emitted from native code.

{ [AdMobPlusEvents.AdClick]: AdMobPlusAdIdPayload; [AdMobPlusEvents.AdDismiss]: AdMobPlusAdIdPayload; [AdMobPlusEvents.AdImpression]: AdMobPlusAdIdPayload; [AdMobPlusEvents.AdLoad]: AdMobPlusAdIdPayload; [AdMobPlusEvents.AdLoadFail]: AdMobPlusAdFailurePayload; [AdMobPlusEvents.AdReward]: AdMobPlusAdRewardPayload; [AdMobPlusEvents.AdShow]: AdMobPlusAdIdPayload; [AdMobPlusEvents.AdShowFail]: AdMobPlusAdFailurePayload; [AdMobPlusEvents.BannerClick]: AdMobPlusAdIdPayload; [AdMobPlusEvents.BannerClose]: AdMobPlusAdIdPayload; [AdMobPlusEvents.BannerImpression]: AdMobPlusAdIdPayload; [AdMobPlusEvents.BannerLoad]: AdMobPlusAdIdPayload; [AdMobPlusEvents.BannerLoadFail]: AdMobPlusAdFailurePayload; [AdMobPlusEvents.BannerOpen]: AdMobPlusAdIdPayload; [AdMobPlusEvents.BannerSizeChange]: AdMobPlusAdIdPayload; [AdMobPlusEvents.InterstitialDismiss]: AdMobPlusAdIdPayload; [AdMobPlusEvents.InterstitialImpression]: AdMobPlusAdIdPayload; [AdMobPlusEvents.InterstitialLoad]: AdMobPlusAdIdPayload; [AdMobPlusEvents.InterstitialLoadFail]: AdMobPlusAdFailurePayload; [AdMobPlusEvents.InterstitialShow]: AdMobPlusAdIdPayload; [AdMobPlusEvents.InterstitialShowFail]: AdMobPlusAdFailurePayload; [AdMobPlusEvents.RewardedDismiss]: AdMobPlusAdIdPayload; [AdMobPlusEvents.RewardedImpression]: AdMobPlusAdIdPayload; [AdMobPlusEvents.RewardedInterstitialDismiss]: AdMobPlusAdIdPayload; [AdMobPlusEvents.RewardedInterstitialImpression]: AdMobPlusAdIdPayload; [AdMobPlusEvents.RewardedInterstitialLoad]: AdMobPlusAdIdPayload; [AdMobPlusEvents.RewardedInterstitialLoadFail]: AdMobPlusAdFailurePayload; [AdMobPlusEvents.RewardedInterstitialReward]: AdMobPlusAdRewardPayload; [AdMobPlusEvents.RewardedInterstitialShow]: AdMobPlusAdIdPayload; [AdMobPlusEvents.RewardedInterstitialShowFail]: AdMobPlusAdFailurePayload; [AdMobPlusEvents.RewardedLoad]: AdMobPlusAdIdPayload; [AdMobPlusEvents.RewardedLoadFail]: AdMobPlusAdFailurePayload; [AdMobPlusEvents.RewardedReward]: AdMobPlusAdRewardPayload; [AdMobPlusEvents.RewardedShow]: AdMobPlusAdIdPayload; [AdMobPlusEvents.RewardedShowFail]: AdMobPlusAdFailurePayload; }

AdMobPlusAdIdPayload

Event payload always includes the native ad instance id (adId). iOS also emits legacy id.

{ adId: number; id?: number; }

AdMobPlusAdFailurePayload

Load and fullscreen show failure payloads from native LoadAdError / FullScreenContentError.

AdMobPlusAdIdPayload & { code: number; message: string; /** Legacy iOS failure field; same string as message when present. */ error?: string; }

AdMobPlusAdRewardPayload

Reward callbacks include the earned reward plus adId.

AdMobPlusAdIdPayload & { reward: { amount: number; type: string; }; }

Enums

MaxAdContentRating

Members Value Description
G 'G' General Audiences
MA 'MA' Mature Audiences
PG 'PG' Parental Guidance
T 'T' Teen
UNSPECIFIED '' Unspecified rating

AdmobConsentStatus

Members Value Description
NOT_REQUIRED 'NOT_REQUIRED' User consent not required.
OBTAINED 'OBTAINED' User consent already obtained.
REQUIRED 'REQUIRED' User consent required but not yet obtained.
UNKNOWN 'UNKNOWN' Unknown consent status. Call requestConsentInfo() to update it.

PrivacyOptionsRequirementStatus

Members Value Description
NOT_REQUIRED 'NOT_REQUIRED' Privacy options entry point is not required.
REQUIRED 'REQUIRED' Privacy options entry point is required.
UNKNOWN 'UNKNOWN' Privacy options requirement status is unknown.

AdmobConsentDebugGeography

Members Value Description
DISABLED 0 Debug geography disabled.
EEA 1 Geography appears as in EEA for debug devices.
NOT_EEA 2 Geography appears as not in EEA for debug devices.
US 3 Geography appears as in a regulated US state for debug devices.
OTHER 4 Geography appears as OTHER for debug devices.

TrackingAuthorizationStatus

Members Value Description
notDetermined 0 User has not yet received an authorization request
restricted 1 User restricted, device is unable to provide authorization
denied 2 User denied authorization
authorized 3 User authorized access

About

Capacitor plugin to bridge AdMob SDKs for iOS and Android

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

14 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages