npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cordova-plugin-admob-nextgen

v1.6.9

Published

Google Mobile Ads Next Gen SDK for Cordova. High performance and modular architecture.

Readme

Cordova AdMob Next-Gen Plugin

Android iOS AdMob Next Gen License

NPM version Downloads License

The Ultimate AdMob Monetization Solution for Cordova/Capacitor/Framework7.

This plugin is a complete rewrite and re-architecture of the classic AdMob integration, built specifically for the Google Mobile Ads Next Generation SDK.

It moves away from legacy implementations to modern SurfaceControl, optimized layouts, and background threading, ensuring maximum performance, stability, and revenue.

Maintained by the original creator of EMI-INDO/emi-indo-cordova-plugin-admob. This is not just an update; it is a brand new engine designed for 2026 and beyond.


🚀 Why Next-Gen?

Google has introduced a fundamental shift in how ads are rendered on Android.

This plugin aligns perfectly with those changes to solve the most critical issues developers face today:

  1. ANR Error Elimination: The legacy SDK is notorious for causing ANR (Application Not Responding) errors in the Google Play Console. This Next-Gen architecture fully resolves these threading bottlenecks. (See Google's Next-Gen Announcement)

  2. Lifecycle Stability: Solves the notorious issue where Full-Screen Ads (Interstitial, Rewarded, App Open) would crash or disappear when the app goes to the background and returns to the foreground.

  3. Smart Runtime Engine (Android 15 Edge-to-Edge): Intelligently detects and handles Android 14 (API 35) vs Android 15 (API 36) edge-to-edge conditions at runtime.

    • Automatically secures the "Close/X" buttons on full-screen ads.
    • When using the banner parameter isOverlapping: false, it intelligently calculates the system safe bottom insets to push the WebView content up perfectly.
    • Ensures neither the ad nor your app UI is hidden behind the system navigation bar.
    • Requires zero manual configuration from the user. (See Release v1.3.9-beta.1)
  4. Cordova & Capacitor Agnostic: Intelligently identifies whether the runtime environment is Cordova or Capacitor (including deep native Java logic adjustments) to provide seamless compatibility.

  5. Clean Architecture: Written from scratch using the official Next Gen SDK Examples, ensuring long-term compliance with Google Policies.

💰 Mission: Revenue Maximization

This plugin is designed with one goal:

increasing your eCPM and fill rates.

It incorporates advanced formats and technologies that are proven to outperform standard implementations.

1. True Next-Gen Speed: Ad Preloading API ⚡

This is the real Next-Gen feature, this plugin implements the specific Preload API methods: startBannerPreload and showPreloadedBanner.

  • Zero Latency: Instead of loading an ad when you need it, the plugin maintains a "pool" of ready-to-show ads in the background.
  • Instant Show: When you call showPreloadedBanner, the ad appears instantly (0ms delay) from the pool.

2. Collapsible Banners (The Revenue Booster)

Standard banners are often ignored by users.

This plugin supports Collapsible Banners natively.

  • Impact: Typically delivers 3-5% higher revenue than standard or large adaptive banners.
  • Mechanism: Shows a larger ad initially (anchored top/bottom) that can be collapsed by the user, drastically increasing visibility and click-through rates (CTR).

3. Native Advanced Overlay (The Banner Killer)

Move beyond simple 320x50 banners.

The Native Overlay feature allows you to render high-performance Native Ads that look like system notifications.

  • Impact: Can yield 5-10% higher revenue compared to standard banners due to higher advertiser demand for Native assets.
  • Smart Templates:
    • banner_bottom: A sleek, notification-style ad docked at the bottom.
    • banner_top: Docked at the top.
    • modal_center: A popup-style native ad.
  • Policy Safe: Includes an isOverlapping parameter.
  • You can choose to overlay the ad (float) or push the webview content (safe layout), preventing accidental clicks.

🛡️ Safety & Reliability

This plugin prioritizes the safety of your AdMob account and the stability of your app.

  • Smart Throttling (retryInterval): Solves the dreaded "high requests, low impressions" (Invalid Traffic / IVT) issue.

  • This parameter acts as a strict anti-spam safeguard.

  • If an ad load is accidentally triggered repeatedly by an app logic error (e.g., game loop, tick, or scroll event) before the ad surfaces and is viewed by the user, the retryInterval automatically blocks the redundant requests.

    Without this safeguard, you face two fatal problems:

    1. Banner Ad Flickering: Ads are constantly being destroyed and redrawn before becoming visible.
    2. Account Ban: Aggressively pulling ads (spamming requests without impressions) is a serious violation of AdMob's Invalid Traffic policy.
  • Background Thread Loading: All ad requests are dispatched on background threads, ensuring your app's UI never freezes.


Cordova/Capacitor/Framework7 AdMob Next-Gen:

Installation & Usage Guide


Fastest test (APK Debug): ⚡ With github action (Optional)


📦 Current SDK Versions (Maintained & Up-to-Date)

This plugin is regularly updated to support the latest standards.

| Component | Platform | Version | Release Notes | | :--- | :--- | :--- | :--- | | GMA Next-Gen SDK | Android | 1.1.1 | View Notes | | UMP SDK | Android | 4.0.0 | View Notes | | Mobile Ads SDK | iOS | 13.3.0 | View Notes | | UMP SDK | iOS | 3.1.0 | View Notes |

🎉 View all plugin release notes


1. Cordova or Framework7

Option A: Via CLI

Install the plugin directly using the Cordova CLI, You must provide your AdMob App ID.

cordova plugin add cordova-plugin-admob-nextgen --save --variable APP_ID_ANDROID="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy" --variable APP_ID_IOS="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"

Option B: Via config.xml

Add this to your config.xml to restore the plugin automatically.

<plugin name="cordova-plugin-admob-nextgen">
    <variable name="APP_ID_ANDROID" value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy" />
    <variable name="APP_ID_IOS" value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy" />
</plugin>

(Optional)

Supporting Mediation: ⚡ admob-mediation-suite (Optional)

Supporting Native ads: ⚡ cordova-plugin-admob-nextgen-native (Optional)


For Capacitor users

⚡ Capacitor Integration: Automated Setup for AdMob Next Gen .

⚡ AdMob Next Gen - Starter Capacitor Templates 🚀 .


⚡ FULL Cordova - simple example 🚀 .

2. Configuration & Initialization (CRITICAL)

IMPORTANT: Configure Global Settings and handle Privacy Consent (UMP) BEFORE initializing the SDK.

Step 1: Global Configuration (Run First)

// Optional: Mute ads globally
admobNextGen.setAppVolume(0.5);
admobNextGen.setAppMuted(true);

Step 2: Request Consent (UMP) & Initialize

// 1. Request Consent Information
admobNextGen.requestConsentInfo({
    debug: false, // Set true for testing
    reset: false,
    tagForUnderAgeOfConsent: false
}, function() {
    console.log("Consent Info Ready.");
    startSdk();

}, function(err) {
    console.error("Consent Error", err);
    startSdk();
});



// --- Consent Events ---
document.addEventListener('on.consent.status.change', (data) => {
    console.log(data);
});
on.consent.info.update
on.consent.form.dismissed
on.consent.status.change  (obj)
on.consent.error  (obj)




// 3. Initialize the SDK
function startSdk() {
    admobNextGen.initialize({
        maxAdContentRating: 'G',  // 'G' | 'PG' | 'T' | 'MA' | ""
        tagForChildDirectedTreatment: false, // true | false | null
        tagForUnderAgeOfConsent: false, // true | false | null
        // isNativeValidatorDisabled: false // optional param for: cordova-plugin-admob-nextgen-native
    }, function() {
        console.log(">>> AdMob SDK Initialized & Ready <<<");
    }, function(err) {
        console.error("SDK Init Failed", err);
    });
}


// 4. Privacy options
    admobNextGen.showPrivacyOptionsForm(function() {
        startSdk();
    }, function(err) {
        startSdk();
    });

App Tracking Transparency (ATT / IDFA) - iOS Only

For iOS 14+, Apple requires you to prompt the user before tracking their IDFA. The plugin provides manual control over this prompt so you can display it at the right time in your app's lifecycle.

function checkAppTracking() {
    admobNextGen.requestTrackingAuthorization(
        function(status) {
            console.log("ATT Status: " + status); 
            // Returns: 'AUTHORIZED', 'DENIED', 'NOT_DETERMINED', 'RESTRICTED'
            
            // Regardless of the ATT choice, initialize the SDK
            startSdk();
        },
        function(err) {
            console.warn("ATT Request Failed", err);
            startSdk();
        }
    );
}

// You can also silently check the status anytime:
// admobNextGen.getTrackingAuthorizationStatus(success, error);

Step 3: Check Consent Status (Smart Analysis)

You can check if the user has granted permission for Personalized Ads without parsing complex IAB strings manually.

admobNextGen.getTCData(function(data) {
    // --- SMART ANALYSIS (Easy) ---
    console.log("Personalized Allowed: " + data.isPersonalizedAllowed); // Boolean: true/false
    console.log("Status: " + data.statusMessage);

    // --- RAW DATA (Expert) ---
    console.log("TC String: " + data.tcString);
    console.log("GDPR Applies: " + data.gdprApplies); // 1=Yes, 0=No
    console.log("Purpose Consents: " + data.purposeConsents);
});

3. Banner Ads

Supports Adaptive, Standard, and Collapsible banners.

Create Banner

admobNextGen.createBanner({
    adUnitId: 'ca-app-pub-xxx/xxx',
    position: 'bottom',       // 'top' or 'bottom'
    size: 'ADAPTIVE',         // 'BANNER', 'LARGE_BANNER', 'MEDIUM_RECTANGLE', 'ADAPTIVE', 'FULL_BANNER', 'LEADERBOARD'
    isOverlapping: false,     // true = Overlay, false = Push Webview
    collapsible: true,        // true = Enable Collapsible Format (High Revenue)
    retryInterval: 5000,      // Anti-spam delay (ms)
    isAutoShow: true
});

New large banner adaptive size

new banner size min plugin version: 1.2+

  • LARGE_LANDSCAPE_ANCHORED_ADAPTIVE
  • LARGE_PORTRAIT_ANCHORED_ADAPTIVE
  • CURRENT_ORIENTATION_INLINE_ADAPTIVE
  • LARGE_ANCHORED_ADAPTIVE
  • PORTRAIT_INLINE_ADAPTIVE

Banner Methods

admobNextGen.showBanner();
admobNextGen.hideBanner();
admobNextGen.removeBanner();

Banner Events

document.addEventListener('on.banner.load', (data) => {
    console.log("Banner Loaded: " + data.width + "x" + data.height);
    console.log("Collapsible: " + data.isCollapsible);
});
document.addEventListener('on.banner.failed', (err) => console.error(err));
document.addEventListener('on.banner.revenue', (data) => {
    console.log("Revenue: " + data.value + " " + data.currency);
});
document.addEventListener('on.banner.clicked', () => console.log("Clicked"));
document.addEventListener('on.banner.impression', () => console.log("Impression"));

// else
on.banner.opened
on.banner.closed
on.banner.failed.show
on.banner.refreshed
on.banner.refresh.failed

4. Native Ads (Advanced Overlay) - Android Only

High-performance native templates.

Example A: Using Templates (Recommended)

// Android Only
admobNextGen.createNativeAd({
    adUnitId: 'ca-app-pub-xxx/xxx',
    view: 'banner_bottom',    // Presets: 'banner_top', 'banner_bottom', 'modal_center'
    isOverlapping: false,     // true = Overlay, false = Push Content
    retryInterval: 5000
});

Example B: Custom Position (Manual Coordinates)

// Android Only
admobNextGen.createNativeAd({
    adUnitId: 'ca-app-pub-xxx/xxx',
    view: 'custom',
    x: 20,              // X Position in dp
    y: 100,             // Y Position in dp
    width: 300,         // Width in dp
    height: 300,        // Height in dp
    isOverlapping: true // Typically true for custom floating ads
});

Native Methods & Events

// Android Only
admobNextGen.removeNativeAd();

document.addEventListener('on.native.loaded', () => console.log("Native Loaded"));
document.addEventListener('on.native.revenue', (data) => console.log("Revenue:", data.value));

// else
on.native.shown
on.native.failed
on.native.dismissed
on.native.show.failed  (obj)
on.native.impression
on.native.clicked

6. App Open Ads

Supports Auto-Resume logic.

Load App Open

admobNextGen.loadAppOpenAd({
    adUnitId: 'ca-app-pub-xxx/xxx',
    isAutoShow: true, // Automatically show when app resumes from background
    retryInterval: 5000
});

Manual Show

admobNextGen.showAppOpenAd();

App Open Events

document.addEventListener('on.appopen.revenue', (data) => console.log(data));
document.addEventListener('on.appopen.dismissed', () => console.log("Closed"));

// else
on.appopen.loaded
on.appopen.failed.load (obj)
on.appopen.failed.show (obj)
on.appopen.revenue (obj)
on.appopen.shown
on.appopen.dismissed
on.appopen.failed.show (obj)
on.appopen.impression
on.appopen.clicked

7. Interstitial Ads

Load & Show

admobNextGen.createInterstitial({
    adUnitId: 'ca-app-pub-xxx/xxx',
    isAutoShow: true, // Show immediately when loaded
    retryInterval: 5000
});

// Manual Show
// admobNextGen.showInterstitial();

Events

document.addEventListener('on.interstitial.revenue', (data) => console.log(data));
document.addEventListener('on.interstitial.dismissed', () => console.log("Closed"));

// else
on.interstitial.loaded
on.interstitial.failed.load (obj)
on.interstitial.failed.show (obj)
on.interstitial.revenue (obj)
on.interstitial.shown
on.interstitial.dismissed
on.interstitial.failed.show (obj)
on.interstitial.impression
on.interstitial.clicked

8. Rewarded Video

Load & Show

admobNextGen.createRewarded({
    adUnitId: 'ca-app-pub-xxx/xxx',
    retryInterval: 5000,  // Anti-spam interval
    isAutoShow: false     // Default false (User must opt-in)
});

// Show manually when ready
admobNextGen.showRewarded();

Events

document.addEventListener('on.rewarded.earned', (data) => {
    console.log("User Earned: " + data.amount + " " + data.type);
});
document.addEventListener('on.rewarded.revenue', (data) => console.log(data));

// else
on.rewarded.loaded
on.rewarded.failed.load (obj)
on.rewarded.failed.show (obj)
on.rewarded.revenue (obj)
on.rewarded.shown
on.rewarded.canceled
on.rewarded.dismissed
on.rewarded.failed.show (obj)
on.rewarded.impression
on.rewarded.clicked

9. Rewarded Interstitial

Auto-showing rewarded format (no opt-in).

Load & Show

admobNextGen.createRewardedInterstitial({
    adUnitId: 'ca-app-pub-xxx/xxx',
    isAutoShow: true,
    retryInterval: 5000 // Anti-spam interval
});

Events

document.addEventListener('on.rewardedInter.earned', (data) => console.log(data));
document.addEventListener('on.rewardedInter.revenue', (data) => console.log(data));

// else
on.rewardedInter.loaded
on.rewardedInter.failed.load (obj)
on.rewardedInter.failed.show (obj)
on.rewardedInter.revenue (obj)
on.rewardedInter.shown
on.rewardedInter.canceled
on.rewardedInter.dismissed
on.rewardedInter.failed.show (obj)
on.rewardedInter.impression
on.rewardedInter.clicked

10. Preloader Engine (Android Only - Next-Gen SDK)

The AdMob Next-Gen SDK introduces a powerful background Preloader Engine that caches ads in a buffer pool, enabling zero-latency ad rendering.

⚠️ IMPORTANT WARNING & BEST PRACTICES:

  • Android Only: The Preloader engine is currently an exclusive feature of the Android Next-Gen SDK.
  • Strict Method Separation: NEVER mix Classic methods with Preloader methods to avoid logic conflicts.
    • If you use createBanner, you MUST use showBanner.
    • If you use startBannerPreload, you MUST use showPreloadedBanner.
  • Cross-Platform (iOS) Consideration: Events are unified. A source flag (data.source === "preloader") is injected into the event data on Android. However, it is highly recommended to maintain a single unified logic flow. Relying strictly on the source === "preloader" condition will cause issues on iOS, as iOS relies entirely on the Classic implementation.

Method Mapping (Classic vs Preloader)

| Ad Format | Start Preload | Show Polled Ad | Other Preload Methods | | :--- | :--- | :--- | :--- | | Banner | startBannerPreload(obj) | showPreloadedBanner() | stopBannerPreload(), hideBannerPreload() | | App Open | startAppOpenPreload(obj) | showPreloadedAppOpenAd() | isAppOpenAdAvailable() | | Interstitial | startInterstitialPreload(obj) | showPreloadedInterstitial() | stopInterstitialPreload(), isInterstitialAdAvailable() | | Rewarded | startRewardedPreload(obj) | showPreloadedRewarded() | stopRewardedPreload(), isRewardedAdAvailable() | | Rewarded Interstitial | startRewardedInterstitialPreload(obj) | showPreloadedRewardedInterstitial() | stopRewardedInterstitialPreload(), isRewardedInterstitialAdAvailable() |

Implementation Example

1. Start the Preloader Run this once (e.g., after SDK initialization). The engine will automatically maintain the buffer in the background.

admobNextGen.startRewardedPreload({
    adUnitId: 'ca-app-pub-xxx/xxx',
    bufferSize: 2,         // (Optional) Number of ads to cache. Default: 1 max 3
    isAutoShow: false,     // (Optional) Show immediately when the first ad is ready
    retryInterval: 5000    // (Optional) Anti-spam protection in ms
});

2. Show the Preloaded Ad Call this when the user interacts with your app. It will render instantly from the local buffer.

admobNextGen.showPreloadedRewarded();

Unified Events & Preloader Exclusives

To streamline development, the Preloader triggers the exact same lifecycle events as the Classic mode (e.g., on.rewarded.loaded, on.rewarded.dismissed). You only need to write one event listener for both modes.

Preloader Exclusive Event: The only event strictly unique to the Preloader is the exhausted event. This fires when the buffer pool is completely empty and the SDK stops trying to fetch new ads.

// Example: Unique Preloader Event
document.addEventListener('on.rewarded.exhausted', () => {
    console.warn("Background ad buffer is empty!");
});

Optional: Checking the Event Source If you need to execute specific conditional logic for the preloader, you can check data.source. (Remember: This flag is Android-only).

document.addEventListener('on.rewarded.loaded', (e) => {
    let data = e.data || e;
    
    if (data && data.source === "preloader") {
        console.log("Ad loaded via Android Preloader Engine");
    } else {
        console.log("Ad loaded via Classic Engine (or iOS)");
    }
});

⚖️ Revenue Policy

No Ad-Sharing. No Hidden Fees.

Unlike many other free plugins, this project is clean:

  • 0% Revenue Share: This plugin do not inject our own Ad Unit IDs into your traffic.
  • 100% Control: Every impression and click goes directly to your AdMob account.
  • Transparent Source: The code is open source. You can verify that no third-party SDKs or hidden backdoors exist.

❤️ Support the Project

This plugin is developed and maintained in my free time. If it saved you hours of work, consider supporting the development!

Your support helps me keep the dependencies updated and the cleaner script running smoothly.