cordova-plugin-admob-nextgen 1.3.9 → 1.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +147 -80
- package/package.json +1 -1
- package/plugin.xml +12 -5
- package/src/android/AdMobNextGen.java +114 -37
- package/src/android/AppOpenAdExecutor.java +7 -0
- package/src/android/BannerExecutor.java +8 -1
- package/src/android/GlobalSettingsExecutor.java +41 -52
- package/src/android/InterstitialExecutor.java +7 -1
- package/src/android/NativeExecutor.java +7 -0
- package/src/android/RewardedExecutor.java +7 -0
- package/src/android/RewardedInterstitialExecutor.java +7 -0
- package/src/android/{AppOpenAdPreloadExecutor.java → preloading/AppOpenAdPreloadExecutor.java} +41 -12
- package/src/android/{BannerPreloadExecutor.java → preloading/BannerPreloadExecutor.java} +96 -21
- package/src/android/preloading/InterstitialPreloadExecutor.java +284 -0
- package/src/android/preloading/RewardedInterstitialPreloadExecutor.java +293 -0
- package/src/android/preloading/RewardedPreloadExecutor.java +292 -0
- package/www/admob-nextgen.js +51 -1
package/README.md
CHANGED
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
**The Ultimate AdMob Monetization Solution for Cordova/Capacitor/Framework7.**
|
|
13
13
|
|
|
14
|
-
This plugin is a complete **rewrite and re-architecture** of the classic AdMob integration, built specifically for the **[Google Mobile Ads Next Generation SDK](https://ads-developers.googleblog.com/2026/01/announcing-google-mobile-ads-next-gen.html)**.
|
|
14
|
+
This plugin is a complete **rewrite and re-architecture** of the classic AdMob integration, built specifically for the **[Google Mobile Ads Next Generation SDK](https://ads-developers.googleblog.com/2026/01/announcing-google-mobile-ads-next-gen.html)**.
|
|
15
|
+
|
|
16
|
+
It moves away from legacy implementations to modern `SurfaceControl`, optimized layouts, and background threading, ensuring maximum performance, stability, and revenue.
|
|
15
17
|
|
|
16
18
|
> **Maintained by the original creator of [EMI-INDO/emi-indo-cordova-plugin-admob](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob).** This is not just an update; it is a brand new engine designed for 2026 and beyond.
|
|
17
19
|
|
|
@@ -19,64 +21,105 @@ This plugin is a complete **rewrite and re-architecture** of the classic AdMob i
|
|
|
19
21
|
|
|
20
22
|
## 🚀 Why Next-Gen?
|
|
21
23
|
|
|
22
|
-
Google has introduced a fundamental shift in how ads are rendered on Android.
|
|
24
|
+
Google has introduced a fundamental shift in how ads are rendered on Android.
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
This plugin aligns perfectly with those changes to solve the most critical issues developers face today:
|
|
27
|
+
|
|
28
|
+
1. **ANR Error Elimination:**
|
|
29
|
+
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.
|
|
30
|
+
*(See [Google's Next-Gen Announcement](https://ads-developers.googleblog.com/2026/01/announcing-google-mobile-ads-next-gen.html))*
|
|
31
|
+
|
|
32
|
+
2. **Lifecycle Stability:**
|
|
33
|
+
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.
|
|
34
|
+
|
|
35
|
+
3. **Smart Runtime Engine (Android 15 Edge-to-Edge):**
|
|
36
|
+
Intelligently detects and handles Android 14 (API 35) vs Android 15 (API 36) edge-to-edge conditions at runtime.
|
|
37
|
+
* Automatically secures the "Close/X" buttons on full-screen ads.
|
|
38
|
+
* When using the banner parameter `isOverlapping: false`, it intelligently calculates the system safe bottom insets to push the WebView content up perfectly.
|
|
39
|
+
* Ensures neither the ad nor your app UI is hidden behind the system navigation bar.
|
|
40
|
+
* Requires **zero** manual configuration from the user.
|
|
41
|
+
*(See [Release v1.3.9-beta.1](https://github.com/swaplab-engine/cordova-plugin-admob-nextgen/releases/tag/v1.3.9-beta.1))*
|
|
42
|
+
|
|
43
|
+
4. **Cordova & Capacitor Agnostic:**
|
|
44
|
+
Intelligently identifies whether the runtime environment is Cordova or Capacitor (including deep native Java logic adjustments) to provide seamless compatibility.
|
|
45
|
+
|
|
46
|
+
5. **Clean Architecture:**
|
|
47
|
+
Written from scratch using the official [Next Gen SDK Examples](https://github.com/googleads/gma-next-gen-sdk-android-examples), ensuring long-term compliance with Google Policies.
|
|
27
48
|
|
|
28
|
-
---
|
|
29
49
|
|
|
30
50
|
## 💰 Mission: Revenue Maximization
|
|
31
51
|
|
|
32
|
-
This plugin is designed with one goal:
|
|
52
|
+
This plugin is designed with one goal:
|
|
53
|
+
|
|
54
|
+
**increasing your eCPM and fill rates**.
|
|
55
|
+
|
|
56
|
+
It incorporates advanced formats and technologies that are proven to outperform standard implementations.
|
|
33
57
|
|
|
34
58
|
### 1. True Next-Gen Speed: Ad Preloading API ⚡
|
|
35
|
-
This is the **real** Next-Gen feature
|
|
59
|
+
This is the **real** Next-Gen feature, this plugin implements the specific Preload API methods: `startBannerPreload` and `showPreloadedBanner`.
|
|
36
60
|
* **Zero Latency:** Instead of loading an ad when you need it, the plugin maintains a "pool" of ready-to-show ads in the background.
|
|
37
61
|
* **Instant Show:** When you call `showPreloadedBanner`, the ad appears instantly (0ms delay) from the pool.
|
|
38
62
|
|
|
39
63
|
### 2. Collapsible Banners (The Revenue Booster)
|
|
40
|
-
Standard banners are often ignored by users.
|
|
41
|
-
|
|
64
|
+
Standard banners are often ignored by users.
|
|
65
|
+
|
|
66
|
+
This plugin supports **Collapsible Banners** natively.
|
|
67
|
+
* **Impact:** Typically delivers **3-5% higher revenue** than standard or large adaptive banners.
|
|
42
68
|
* **Mechanism:** Shows a larger ad initially (anchored top/bottom) that can be collapsed by the user, drastically increasing visibility and click-through rates (CTR).
|
|
43
69
|
|
|
44
70
|
### 3. Native Advanced Overlay (The Banner Killer)
|
|
45
|
-
Move beyond simple 320x50 banners.
|
|
71
|
+
Move beyond simple 320x50 banners.
|
|
72
|
+
|
|
73
|
+
The Native Overlay feature allows you to render high-performance Native Ads that look like system notifications.
|
|
46
74
|
* **Impact:** Can yield **5-10% higher revenue** compared to standard banners due to higher advertiser demand for Native assets.
|
|
47
75
|
* **Smart Templates:**
|
|
48
76
|
* `banner_bottom`: A sleek, notification-style ad docked at the bottom.
|
|
49
77
|
* `banner_top`: Docked at the top.
|
|
50
78
|
* `modal_center`: A popup-style native ad.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
---
|
|
79
|
+
* **Policy Safe:** Includes an `isOverlapping` parameter.
|
|
80
|
+
* You can choose to overlay the ad (float) or push the webview content (safe layout), preventing accidental clicks.
|
|
54
81
|
|
|
55
82
|
|
|
56
83
|
## 🛡️ Safety & Reliability
|
|
57
84
|
|
|
58
|
-
|
|
85
|
+
This plugin prioritizes the safety of your AdMob account and the stability of your app.
|
|
59
86
|
|
|
60
|
-
* **Smart Throttling (`retryInterval`)**:
|
|
87
|
+
* **Smart Throttling (`retryInterval`)**: Solves the dreaded "high requests, low impressions" (Invalid Traffic / IVT) issue.
|
|
61
88
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
89
|
+
* This parameter acts as a strict anti-spam safeguard.
|
|
90
|
+
* 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.
|
|
91
|
+
|
|
92
|
+
**Without this safeguard, you face two fatal problems:**
|
|
93
|
+
1. **Banner Ad Flickering:** Ads are constantly being destroyed and redrawn before becoming visible.
|
|
94
|
+
2. **Account Ban:** Aggressively pulling ads (spamming requests without impressions) is a serious violation of AdMob's Invalid Traffic policy.
|
|
66
95
|
|
|
67
96
|
* **Background Thread Loading**: All ad requests are dispatched on background threads, ensuring your app's UI never freezes.
|
|
68
97
|
|
|
98
|
+
|
|
69
99
|
---
|
|
70
100
|
|
|
71
101
|
|
|
72
|
-
## Cordova/Capacitor/Framework7 AdMob Next-Gen:
|
|
102
|
+
## Cordova/Capacitor/Framework7 AdMob Next-Gen:
|
|
103
|
+
|
|
104
|
+
### Installation & Usage Guide
|
|
73
105
|
|
|
74
106
|
---
|
|
75
107
|
> Fastest test (APK Debug): **[⚡ With github action ](https://github.com/swaplab-engine/cordova-plugin-admob-nextgen/discussions/4)** (Optional)
|
|
76
108
|
---
|
|
77
109
|
|
|
110
|
+
### 📦 Current SDK Versions (Maintained & Up-to-Date)
|
|
111
|
+
|
|
112
|
+
This plugin is regularly updated to support the latest standards.
|
|
113
|
+
|
|
114
|
+
| Component | Platform | Version | Release Notes |
|
|
115
|
+
| :--- | :--- | :--- | :--- |
|
|
116
|
+
| **GMA Next-Gen SDK** | Android | **1.1.0** | [View Notes](https://developers.google.com/admob/android/next-gen/rel-notes) |
|
|
117
|
+
| **UMP SDK** | Android | **4.0.0** | [View Notes](https://developers.google.com/admob/android/privacy/release-notes) |
|
|
118
|
+
| **Mobile Ads SDK** | iOS | **13.3.0** | [View Notes](https://developers.google.com/admob/ios/rel-notes) |
|
|
119
|
+
| **UMP SDK** | iOS | **3.1.0** | [View Notes](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/privacy/download) |
|
|
120
|
+
|
|
78
121
|
### 🎉 View all plugin release notes
|
|
79
|
-
- 👉 [**Releases**](https://github.com/swaplab-engine/cordova-plugin-admob-nextgen/releases)
|
|
122
|
+
- 👉 [**Releases notes**](https://github.com/swaplab-engine/cordova-plugin-admob-nextgen/releases)
|
|
80
123
|
|
|
81
124
|
---
|
|
82
125
|
|
|
@@ -84,14 +127,14 @@ We prioritize the safety of your AdMob account and the stability of your app.
|
|
|
84
127
|
## 1. Cordova or Framework7
|
|
85
128
|
|
|
86
129
|
### Option A: Via CLI
|
|
87
|
-
Install the plugin directly using the Cordova CLI
|
|
130
|
+
Install the plugin directly using the Cordova CLI, You must provide your AdMob App ID.
|
|
88
131
|
|
|
89
132
|
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"
|
|
90
133
|
|
|
91
134
|
### Option B: Via config.xml
|
|
92
135
|
Add this to your `config.xml` to restore the plugin automatically.
|
|
93
136
|
|
|
94
|
-
<plugin name="cordova-plugin-admob-nextgen"
|
|
137
|
+
<plugin name="cordova-plugin-admob-nextgen">
|
|
95
138
|
<variable name="APP_ID_ANDROID" value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy" />
|
|
96
139
|
<variable name="APP_ID_IOS" value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy" />
|
|
97
140
|
</plugin>
|
|
@@ -318,57 +361,6 @@ High-performance native templates.
|
|
|
318
361
|
|
|
319
362
|
---
|
|
320
363
|
|
|
321
|
-
## 5. Ad Preloading (Banner) - Android Only
|
|
322
|
-
|
|
323
|
-
Use the background engine to pool ads for 0ms latency.
|
|
324
|
-
|
|
325
|
-
### Usage
|
|
326
|
-
|
|
327
|
-
// 1. Start Engine
|
|
328
|
-
admobNextGen.startBannerPreload({
|
|
329
|
-
adUnitId: 'ca-app-pub-xxx/xxx',
|
|
330
|
-
size: 'ADAPTIVE', // 'BANNER', 'LARGE_BANNER', 'MEDIUM_RECTANGLE', 'ADAPTIVE', 'FULL_BANNER', 'LEADERBOARD'
|
|
331
|
-
position: 'bottom', // 'top' or 'bottom'
|
|
332
|
-
collapsible: false, // true = Enable Collapsible Format (High Revenue)
|
|
333
|
-
isOverlapping: false,
|
|
334
|
-
retryInterval: 5000 // Anti-spam delay (ms)
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
// 2. Show Instantly (from pool)
|
|
338
|
-
admobNextGen.showPreloadedBanner();
|
|
339
|
-
|
|
340
|
-
// 3. Stop/Remove Engine
|
|
341
|
-
admobNextGen.stopBannerPreload();
|
|
342
|
-
|
|
343
|
-
// 4. Hide Engine
|
|
344
|
-
admobNextGen.hideBannerPreload()
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
### Banner Events
|
|
348
|
-
|
|
349
|
-
document.addEventListener('on.banner.load', (data) => {
|
|
350
|
-
console.log("Banner Loaded: " + data.width + "x" + data.height);
|
|
351
|
-
console.log("Collapsible: " + data.isCollapsible);
|
|
352
|
-
});
|
|
353
|
-
document.addEventListener('on.preload.failed', (err) => console.error(err));
|
|
354
|
-
document.addEventListener('on.banner.revenue', (data) => {
|
|
355
|
-
console.log("Revenue: " + data.value + " " + data.currency);
|
|
356
|
-
});
|
|
357
|
-
document.addEventListener('on.banner.clicked', () => console.log("Clicked"));
|
|
358
|
-
document.addEventListener('on.banner.impression', () => console.log("Impression"));
|
|
359
|
-
|
|
360
|
-
// else
|
|
361
|
-
on.preload.available
|
|
362
|
-
on.preload.failed
|
|
363
|
-
on.preload.exhausted
|
|
364
|
-
on.banner.opened
|
|
365
|
-
on.banner.closed
|
|
366
|
-
on.banner.failed.show
|
|
367
|
-
on.banner.refreshed
|
|
368
|
-
on.banner.refresh.failed
|
|
369
|
-
|
|
370
|
-
---
|
|
371
|
-
|
|
372
364
|
## 6. App Open Ads
|
|
373
365
|
|
|
374
366
|
Supports Auto-Resume logic.
|
|
@@ -385,9 +377,6 @@ Supports Auto-Resume logic.
|
|
|
385
377
|
|
|
386
378
|
admobNextGen.showAppOpenAd();
|
|
387
379
|
|
|
388
|
-
### With App Open Ad Preload
|
|
389
|
-
> App Open Ad Preload **[⚡ Modern ](https://github.com/swaplab-engine/cordova-plugin-admob-nextgen/tree/main/simple-example/www/js/AppOpenAdPreload.js)**
|
|
390
|
-
|
|
391
380
|
### App Open Events
|
|
392
381
|
|
|
393
382
|
document.addEventListener('on.appopen.revenue', (data) => console.log(data));
|
|
@@ -504,12 +493,89 @@ Auto-showing rewarded format (no opt-in).
|
|
|
504
493
|
|
|
505
494
|
---
|
|
506
495
|
|
|
496
|
+
|
|
497
|
+
## 10. Preloader Engine (Android Only - Next-Gen SDK)
|
|
498
|
+
|
|
499
|
+
The AdMob Next-Gen SDK introduces a powerful background Preloader Engine that caches ads in a buffer pool, enabling zero-latency ad rendering.
|
|
500
|
+
|
|
501
|
+
> **⚠️ IMPORTANT WARNING & BEST PRACTICES:**
|
|
502
|
+
> * **Android Only:** The Preloader engine is currently an exclusive feature of the Android Next-Gen SDK.
|
|
503
|
+
> * **Strict Method Separation:** NEVER mix Classic methods with Preloader methods to avoid logic conflicts.
|
|
504
|
+
> * If you use `createBanner`, you MUST use `showBanner`.
|
|
505
|
+
> * If you use `startBannerPreload`, you MUST use `showPreloadedBanner`.
|
|
506
|
+
> * **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.
|
|
507
|
+
|
|
508
|
+
### Method Mapping (Classic vs Preloader)
|
|
509
|
+
|
|
510
|
+
| Ad Format | Start Preload | Show Polled Ad | Other Preload Methods |
|
|
511
|
+
| :--- | :--- | :--- | :--- |
|
|
512
|
+
| **Banner** | `startBannerPreload(obj)` | `showPreloadedBanner()` | `stopBannerPreload()`, `hideBannerPreload()` |
|
|
513
|
+
| **App Open** | `startAppOpenPreload(obj)` | `showPreloadedAppOpenAd()` | `isAppOpenAdAvailable()` |
|
|
514
|
+
| **Interstitial** | `startInterstitialPreload(obj)` | `showPreloadedInterstitial()` | `stopInterstitialPreload()`, `isInterstitialAdAvailable()` |
|
|
515
|
+
| **Rewarded** | `startRewardedPreload(obj)` | `showPreloadedRewarded()` | `stopRewardedPreload()`, `isRewardedAdAvailable()` |
|
|
516
|
+
| **Rewarded Interstitial** | `startRewardedInterstitialPreload(obj)` | `showPreloadedRewardedInterstitial()` | `stopRewardedInterstitialPreload()`, `isRewardedInterstitialAdAvailable()` |
|
|
517
|
+
|
|
518
|
+
### Implementation Example
|
|
519
|
+
|
|
520
|
+
- [⚡ Example preloading ](https://github.com/swaplab-engine/cordova-plugin-admob-nextgen/tree/main/simple-example/www/js/preloading)
|
|
521
|
+
|
|
522
|
+
**1. Start the Preloader**
|
|
523
|
+
Run this once (e.g., after SDK initialization). The engine will automatically maintain the buffer in the background.
|
|
524
|
+
|
|
525
|
+
```javascript
|
|
526
|
+
admobNextGen.startRewardedPreload({
|
|
527
|
+
adUnitId: 'ca-app-pub-xxx/xxx',
|
|
528
|
+
bufferSize: 2, // (Optional) Number of ads to cache. Default: 1 max 3
|
|
529
|
+
isAutoShow: false, // (Optional) Show immediately when the first ad is ready
|
|
530
|
+
retryInterval: 5000 // (Optional) Anti-spam protection in ms
|
|
531
|
+
});
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
**2. Show the Preloaded Ad**
|
|
535
|
+
Call this when the user interacts with your app. It will render instantly from the local buffer.
|
|
536
|
+
|
|
537
|
+
```javascript
|
|
538
|
+
admobNextGen.showPreloadedRewarded();
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
### Unified Events & Preloader Exclusives
|
|
542
|
+
|
|
543
|
+
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.
|
|
544
|
+
|
|
545
|
+
**Preloader Exclusive Event:**
|
|
546
|
+
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.
|
|
547
|
+
|
|
548
|
+
```javascript
|
|
549
|
+
// Example: Unique Preloader Event
|
|
550
|
+
document.addEventListener('on.rewarded.exhausted', () => {
|
|
551
|
+
console.warn("Background ad buffer is empty!");
|
|
552
|
+
});
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
**Optional: Checking the Event Source**
|
|
556
|
+
If you need to execute specific conditional logic for the preloader, you can check `data.source`. *(Remember: This flag is Android-only).*
|
|
557
|
+
|
|
558
|
+
```javascript
|
|
559
|
+
document.addEventListener('on.rewarded.loaded', (e) => {
|
|
560
|
+
let data = e.data || e;
|
|
561
|
+
|
|
562
|
+
if (data && data.source === "preloader") {
|
|
563
|
+
console.log("Ad loaded via Android Preloader Engine");
|
|
564
|
+
} else {
|
|
565
|
+
console.log("Ad loaded via Classic Engine (or iOS)");
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
---
|
|
571
|
+
|
|
572
|
+
|
|
507
573
|
## ⚖️ Revenue Policy
|
|
508
574
|
|
|
509
575
|
**No Ad-Sharing. No Hidden Fees.**
|
|
510
576
|
|
|
511
577
|
Unlike many other free plugins, this project is clean:
|
|
512
|
-
* **0% Revenue Share:**
|
|
578
|
+
* **0% Revenue Share:** This plugin do not inject our own Ad Unit IDs into your traffic.
|
|
513
579
|
* **100% Control:** Every impression and click goes directly to your AdMob account.
|
|
514
580
|
* **Transparent Source:** The code is open source. You can verify that no third-party SDKs or hidden backdoors exist.
|
|
515
581
|
|
|
@@ -517,7 +583,8 @@ Unlike many other free plugins, this project is clean:
|
|
|
517
583
|
|
|
518
584
|
## ❤️ Support the Project
|
|
519
585
|
|
|
520
|
-
This plugin is developed and maintained in my free time.
|
|
586
|
+
This plugin is developed and maintained in my free time.
|
|
587
|
+
If it saved you hours of work, consider supporting the development!
|
|
521
588
|
|
|
522
589
|
<a href="https://www.buymeacoffee.com/emi.indo" target="_blank">
|
|
523
590
|
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" >
|
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
2
|
<plugin id="cordova-plugin-admob-nextgen"
|
|
3
|
-
version="1.
|
|
3
|
+
version="1.4.9"
|
|
4
4
|
xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
5
5
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
6
6
|
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
<uses-permission android:name="android.permission.INTERNET" />
|
|
29
29
|
</config-file>
|
|
30
30
|
|
|
31
|
+
<!-- hooks: Prevent conflicts with legacy SDKs when using mediation -->
|
|
31
32
|
<framework src="src/android/hooks/admob-nextgen.gradle" custom="true" type="gradleReference" />
|
|
32
33
|
|
|
33
34
|
<framework src="com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk:$NEXT_GEN_SDK_VERSION" />
|
|
34
35
|
<framework src="com.google.android.ump:user-messaging-platform:$UMP_VERSION" />
|
|
35
36
|
|
|
37
|
+
<!-- Android | IOS -->
|
|
36
38
|
<source-file src="src/android/AdMobNextGen.java" target-dir="app/src/main/java/com/emi/cordova/admob/nextgen" />
|
|
37
39
|
<source-file src="src/android/BannerExecutor.java" target-dir="app/src/main/java/com/emi/cordova/admob/nextgen" />
|
|
38
|
-
<source-file src="src/android/BannerPreloadExecutor.java" target-dir="app/src/main/java/com/emi/cordova/admob/nextgen" />
|
|
39
|
-
<source-file src="src/android/AppOpenAdPreloadExecutor.java" target-dir="app/src/main/java/com/emi/cordova/admob/nextgen" />
|
|
40
40
|
<source-file src="src/android/NativeExecutor.java" target-dir="app/src/main/java/com/emi/cordova/admob/nextgen" />
|
|
41
41
|
<source-file src="src/android/AppOpenAdExecutor.java" target-dir="app/src/main/java/com/emi/cordova/admob/nextgen" />
|
|
42
42
|
<source-file src="src/android/InterstitialExecutor.java" target-dir="app/src/main/java/com/emi/cordova/admob/nextgen" />
|
|
@@ -44,11 +44,18 @@
|
|
|
44
44
|
<source-file src="src/android/RewardedInterstitialExecutor.java" target-dir="app/src/main/java/com/emi/cordova/admob/nextgen" />
|
|
45
45
|
<source-file src="src/android/ConsentExecutor.java" target-dir="app/src/main/java/com/emi/cordova/admob/nextgen" />
|
|
46
46
|
<source-file src="src/android/GlobalSettingsExecutor.java" target-dir="app/src/main/java/com/emi/cordova/admob/nextgen" />
|
|
47
|
+
<!-- Only Android -->
|
|
48
|
+
<source-file src="src/android/preloading/AppOpenAdPreloadExecutor.java" target-dir="app/src/main/java/com/emi/cordova/admob/nextgen/preloading" />
|
|
49
|
+
<source-file src="src/android/preloading/BannerPreloadExecutor.java" target-dir="app/src/main/java/com/emi/cordova/admob/nextgen/preloading" />
|
|
50
|
+
<source-file src="src/android/preloading/InterstitialPreloadExecutor.java" target-dir="src/com/emi/cordova/admob/nextgen/preloading" />
|
|
51
|
+
<source-file src="src/android/preloading/RewardedPreloadExecutor.java" target-dir="src/com/emi/cordova/admob/nextgen/preloading" />
|
|
52
|
+
<source-file src="src/android/preloading/RewardedInterstitialPreloadExecutor.java" target-dir="src/com/emi/cordova/admob/nextgen/preloading" />
|
|
47
53
|
|
|
48
54
|
</platform>
|
|
49
55
|
|
|
50
|
-
<preference name="NEXT_GEN_SDK_VERSION" default="1.0
|
|
56
|
+
<preference name="NEXT_GEN_SDK_VERSION" default="1.1.0" />
|
|
51
57
|
<preference name="UMP_VERSION" default="4.0.0" />
|
|
58
|
+
<!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
|
|
52
59
|
<preference name="APP_ID_ANDROID" default="ca-app-pub-3940256099942544~3347511713" />
|
|
53
60
|
|
|
54
61
|
<platform name="ios">
|
|
@@ -152,7 +159,7 @@
|
|
|
152
159
|
<header-file src="src/ios/RewardedInterstitialExecutor.h" />
|
|
153
160
|
<source-file src="src/ios/RewardedInterstitialExecutor.m" />
|
|
154
161
|
</platform>
|
|
155
|
-
|
|
162
|
+
<!-- Sample AdMob app ID: ca-app-pub-3940256099942544~1458002511 -->
|
|
156
163
|
<preference name="APP_ID_IOS" default="ca-app-pub-3940256099942544~1458002511" />
|
|
157
164
|
|
|
158
165
|
</plugin>
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
package com.emi.cordova.admob.nextgen;
|
|
2
2
|
|
|
3
|
+
import com.emi.cordova.admob.nextgen.preloading.AppOpenAdPreloadExecutor;
|
|
4
|
+
import com.emi.cordova.admob.nextgen.preloading.BannerPreloadExecutor;
|
|
5
|
+
import com.emi.cordova.admob.nextgen.preloading.InterstitialPreloadExecutor;
|
|
6
|
+
import com.emi.cordova.admob.nextgen.preloading.RewardedPreloadExecutor;
|
|
7
|
+
import com.emi.cordova.admob.nextgen.preloading.RewardedInterstitialPreloadExecutor;
|
|
8
|
+
|
|
3
9
|
import android.app.Activity;
|
|
4
10
|
import android.app.Application;
|
|
5
11
|
import android.content.Context;
|
|
@@ -40,8 +46,12 @@ public class AdMobNextGen extends CordovaPlugin {
|
|
|
40
46
|
|
|
41
47
|
private BannerPreloadExecutor bannerPreloadExecutor;
|
|
42
48
|
private AppOpenAdPreloadExecutor appOpenAdPreloadExecutor;
|
|
49
|
+
private InterstitialPreloadExecutor interstitialPreloadExecutor;
|
|
50
|
+
private RewardedPreloadExecutor rewardedPreloadExecutor;
|
|
51
|
+
private RewardedInterstitialPreloadExecutor rewardedInterstitialPreloadExecutor;
|
|
43
52
|
|
|
44
53
|
private boolean isNativeValidatorDisabled = true;
|
|
54
|
+
public static boolean isInitialized = false;
|
|
45
55
|
|
|
46
56
|
@Override
|
|
47
57
|
public void pluginInitialize() {
|
|
@@ -49,19 +59,24 @@ public class AdMobNextGen extends CordovaPlugin {
|
|
|
49
59
|
|
|
50
60
|
applyAdMobAPI35WorkaroundIfNeeded(cordova.getActivity().getApplication());
|
|
51
61
|
|
|
62
|
+
globalSettingsExecutor = new GlobalSettingsExecutor(cordova);
|
|
63
|
+
consentExecutor = new ConsentExecutor(cordova, webView);
|
|
64
|
+
appOpenAdExecutor = AppOpenAdExecutor.getInstance();
|
|
65
|
+
appOpenAdExecutor.initialize(cordova, webView);
|
|
66
|
+
|
|
52
67
|
bannerExecutor = new BannerExecutor(cordova, webView);
|
|
53
68
|
interstitialExecutor = new InterstitialExecutor(cordova, webView);
|
|
54
69
|
rewardedExecutor = new RewardedExecutor(cordova, webView);
|
|
55
70
|
rewardedInterstitialExecutor = new RewardedInterstitialExecutor(cordova, webView);
|
|
56
|
-
consentExecutor = new ConsentExecutor(cordova, webView);
|
|
57
|
-
globalSettingsExecutor = new GlobalSettingsExecutor(cordova);
|
|
58
71
|
|
|
59
|
-
appOpenAdExecutor = AppOpenAdExecutor.getInstance();
|
|
60
|
-
appOpenAdExecutor.initialize(cordova, webView);
|
|
61
72
|
nativeExecutor = new NativeExecutor(cordova, webView);
|
|
62
73
|
|
|
63
|
-
bannerPreloadExecutor = new BannerPreloadExecutor(cordova, webView);
|
|
64
74
|
appOpenAdPreloadExecutor = new AppOpenAdPreloadExecutor(cordova, webView);
|
|
75
|
+
bannerPreloadExecutor = new BannerPreloadExecutor(cordova, webView);
|
|
76
|
+
interstitialPreloadExecutor = new InterstitialPreloadExecutor(cordova, webView);
|
|
77
|
+
rewardedPreloadExecutor = new RewardedPreloadExecutor(cordova, webView);
|
|
78
|
+
rewardedInterstitialPreloadExecutor = new RewardedInterstitialPreloadExecutor(cordova, webView);
|
|
79
|
+
|
|
65
80
|
}
|
|
66
81
|
|
|
67
82
|
@Override
|
|
@@ -115,44 +130,12 @@ public class AdMobNextGen extends CordovaPlugin {
|
|
|
115
130
|
return true;
|
|
116
131
|
}
|
|
117
132
|
|
|
118
|
-
if ("startBannerPreload".equals(action)) {
|
|
119
|
-
bannerPreloadExecutor.startPreload(args, callbackContext);
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
if ("showPreloadedBanner".equals(action)) {
|
|
123
|
-
bannerPreloadExecutor.showPolledAd(args, callbackContext);
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
if ("stopBannerPreload".equals(action)) {
|
|
127
|
-
bannerPreloadExecutor.stopPreloadAndClear();
|
|
128
|
-
callbackContext.success();
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if ("hideBannerPreload".equals(action)) {
|
|
133
|
-
bannerPreloadExecutor.hideBanner(callbackContext);
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
133
|
if ("removeBanner".equals(action)) {
|
|
138
134
|
bannerExecutor.destroy();
|
|
139
135
|
callbackContext.success();
|
|
140
136
|
return true;
|
|
141
137
|
}
|
|
142
138
|
|
|
143
|
-
if ("startAppOpenPreload".equals(action)) {
|
|
144
|
-
appOpenAdPreloadExecutor.startPreload(args, callbackContext);
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
if ("showPreloadedAppOpenAd".equals(action)) {
|
|
148
|
-
appOpenAdPreloadExecutor.showPolledAd(args, callbackContext);
|
|
149
|
-
return true;
|
|
150
|
-
}
|
|
151
|
-
if ("isAppOpenAdAvailable".equals(action)) {
|
|
152
|
-
appOpenAdPreloadExecutor.checkAdAvailable(args, callbackContext);
|
|
153
|
-
return true;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
139
|
if ("loadAppOpenAd".equals(action)) {
|
|
157
140
|
if (appOpenAdExecutor != null) {
|
|
158
141
|
appOpenAdExecutor.loadAd(args, callbackContext);
|
|
@@ -181,6 +164,7 @@ public class AdMobNextGen extends CordovaPlugin {
|
|
|
181
164
|
nativeExecutor.createNativeAd(args, callbackContext);
|
|
182
165
|
return true;
|
|
183
166
|
}
|
|
167
|
+
|
|
184
168
|
if ("removeNativeAd".equals(action)) {
|
|
185
169
|
nativeExecutor.removeNativeAd();
|
|
186
170
|
callbackContext.success();
|
|
@@ -189,6 +173,7 @@ public class AdMobNextGen extends CordovaPlugin {
|
|
|
189
173
|
|
|
190
174
|
if ("createInterstitial".equals(action)) {
|
|
191
175
|
interstitialExecutor.createInterstitial(args, callbackContext);
|
|
176
|
+
callbackContext.success();
|
|
192
177
|
return true;
|
|
193
178
|
}
|
|
194
179
|
if ("showInterstitial".equals(action)) {
|
|
@@ -200,6 +185,7 @@ public class AdMobNextGen extends CordovaPlugin {
|
|
|
200
185
|
rewardedExecutor.createRewarded(args, callbackContext);
|
|
201
186
|
return true;
|
|
202
187
|
}
|
|
188
|
+
|
|
203
189
|
if ("showRewarded".equals(action)) {
|
|
204
190
|
rewardedExecutor.showRewarded(callbackContext);
|
|
205
191
|
return true;
|
|
@@ -209,11 +195,101 @@ public class AdMobNextGen extends CordovaPlugin {
|
|
|
209
195
|
rewardedInterstitialExecutor.createRewardedInterstitial(args, callbackContext);
|
|
210
196
|
return true;
|
|
211
197
|
}
|
|
198
|
+
|
|
212
199
|
if ("showRewardedInterstitial".equals(action)) {
|
|
213
200
|
rewardedInterstitialExecutor.showRewardedInterstitial(callbackContext);
|
|
214
201
|
return true;
|
|
215
202
|
}
|
|
216
203
|
|
|
204
|
+
if ("startAppOpenPreload".equals(action)) {
|
|
205
|
+
appOpenAdPreloadExecutor.startPreload(args, callbackContext);
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
if ("showPreloadedAppOpenAd".equals(action)) {
|
|
209
|
+
appOpenAdPreloadExecutor.showPolledAd(args, callbackContext);
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
if ("isAppOpenAdAvailable".equals(action)) {
|
|
213
|
+
appOpenAdPreloadExecutor.checkAdAvailable(args, callbackContext);
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if ("startBannerPreload".equals(action)) {
|
|
218
|
+
bannerPreloadExecutor.startPreload(args, callbackContext);
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
if ("showPreloadedBanner".equals(action)) {
|
|
222
|
+
bannerPreloadExecutor.showPolledAd(args, callbackContext);
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
if ("stopBannerPreload".equals(action)) {
|
|
226
|
+
bannerPreloadExecutor.stopPreloadAndClear();
|
|
227
|
+
callbackContext.success();
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if ("hideBannerPreload".equals(action)) {
|
|
232
|
+
bannerPreloadExecutor.hideBanner(callbackContext);
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if ("startInterstitialPreload".equals(action)) {
|
|
237
|
+
interstitialPreloadExecutor.startPreload(args, callbackContext);
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
if ("showPreloadedInterstitial".equals(action)) {
|
|
241
|
+
interstitialPreloadExecutor.showPolledAd(args, callbackContext);
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
if ("isInterstitialAdAvailable".equals(action)) {
|
|
245
|
+
interstitialPreloadExecutor.checkAdAvailable(args, callbackContext);
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
if ("stopInterstitialPreload".equals(action)) {
|
|
249
|
+
interstitialPreloadExecutor.stopPreloadAndClear(callbackContext);
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if ("startRewardedPreload".equals(action)) {
|
|
254
|
+
rewardedPreloadExecutor.startPreload(args, callbackContext);
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if ("showPreloadedRewarded".equals(action)) {
|
|
259
|
+
rewardedPreloadExecutor.showPolledAd(args, callbackContext);
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if ("isRewardedAdAvailable".equals(action)) {
|
|
264
|
+
rewardedPreloadExecutor.checkAdAvailable(args, callbackContext);
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if ("stopRewardedPreload".equals(action)) {
|
|
269
|
+
rewardedPreloadExecutor.stopPreloadAndClear(callbackContext);
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if ("startRewardedInterstitialPreload".equals(action)) {
|
|
274
|
+
rewardedInterstitialPreloadExecutor.startPreload(args, callbackContext);
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if ("showPreloadedRewardedInterstitial".equals(action)) {
|
|
279
|
+
rewardedInterstitialPreloadExecutor.showPolledAd(args, callbackContext);
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if ("isRewardedInterstitialAdAvailable".equals(action)) {
|
|
284
|
+
rewardedInterstitialPreloadExecutor.checkAdAvailable(args, callbackContext);
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if ("stopRewardedInterstitialPreload".equals(action)) {
|
|
289
|
+
rewardedInterstitialPreloadExecutor.stopPreloadAndClear(callbackContext);
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
|
|
217
293
|
return false;
|
|
218
294
|
}
|
|
219
295
|
|
|
@@ -262,6 +338,7 @@ public class AdMobNextGen extends CordovaPlugin {
|
|
|
262
338
|
cordova.getActivity(),
|
|
263
339
|
config,
|
|
264
340
|
initializationStatus -> {
|
|
341
|
+
isInitialized = true;
|
|
265
342
|
cordova.getActivity().runOnUiThread(() -> callbackContext.success("Initialized"));
|
|
266
343
|
}
|
|
267
344
|
);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
package com.emi.cordova.admob.nextgen;
|
|
2
2
|
|
|
3
|
+
import static com.emi.cordova.admob.nextgen.AdMobNextGen.isInitialized;
|
|
4
|
+
|
|
3
5
|
import android.app.Activity;
|
|
4
6
|
import android.util.Log;
|
|
5
7
|
|
|
@@ -56,6 +58,10 @@ public class AppOpenAdExecutor {
|
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
public void loadAd(JSONArray args, CallbackContext callbackContext) {
|
|
61
|
+
if (!isInitialized) {
|
|
62
|
+
callbackContext.error("SDK not initialized");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
59
65
|
try {
|
|
60
66
|
JSONObject options = args.optJSONObject(0);
|
|
61
67
|
String adUnitId;
|
|
@@ -89,6 +95,7 @@ public class AppOpenAdExecutor {
|
|
|
89
95
|
}
|
|
90
96
|
|
|
91
97
|
if ((currentTime - lastLoadTime) < minLoadInterval) {
|
|
98
|
+
if (callbackContext != null) callbackContext.error("Request too fast. Please wait " + minLoadInterval + " ms to prevent invalid traffic.");
|
|
92
99
|
return;
|
|
93
100
|
}
|
|
94
101
|
|