cordova-plugin-admob-nextgen 1.0.4 → 1.0.6
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 +12 -9
- package/capacitor-hook-admob-ids.js +7 -7
- package/package.json +1 -1
- package/plugin.xml +2 -3
- package/src/android/AppOpenAdExecutor.java +0 -4
- package/src/android/RewardedExecutor.java +10 -0
- package/src/android/RewardedInterstitialExecutor.java +9 -0
- package/src/ios/AppOpenAdExecutor.m +0 -4
- package/src/ios/RewardedExecutor.m +9 -0
- package/src/ios/RewardedInterstitialExecutor.m +9 -0
package/README.md
CHANGED
|
@@ -87,8 +87,10 @@ Add this to your `config.xml` to restore the plugin automatically.
|
|
|
87
87
|
</plugin>
|
|
88
88
|
|
|
89
89
|
|
|
90
|
+
## Supporting Mediation: **[⚡ admob-mediation-suite ](https://github.com/swaplab-engine/admob-mediation-suite)** (Optional)
|
|
91
|
+
|
|
90
92
|
## For Capacitor users
|
|
91
|
-
**[⚡ Capacitor Integration: Automated Setup for AdMob Next Gen ](https://github.com/swaplab-engine/cordova-plugin-admob-nextgen/discussions/
|
|
93
|
+
**[⚡ Capacitor Integration: Automated Setup for AdMob Next Gen ](https://github.com/swaplab-engine/cordova-plugin-admob-nextgen/discussions/3)**.
|
|
92
94
|
|
|
93
95
|
**[⚡ AdMob Next Gen - Starter Templates 🚀 ](https://github.com/swaplab-engine/cordova-plugin-admob-nextgen-template)**.
|
|
94
96
|
|
|
@@ -102,12 +104,6 @@ Add this to your `config.xml` to restore the plugin automatically.
|
|
|
102
104
|
|
|
103
105
|
### Step 1: Global Configuration (Run First)
|
|
104
106
|
|
|
105
|
-
admobNextGen.setRequestConfiguration({
|
|
106
|
-
maxAdContentRating: 'G', // 'G', 'PG', 'T', 'MA'
|
|
107
|
-
tagForChildDirectedTreatment: true, // true/false/null
|
|
108
|
-
tagForUnderAgeOfConsent: true // true/false/null
|
|
109
|
-
});
|
|
110
|
-
|
|
111
107
|
// Optional: Mute ads globally
|
|
112
108
|
admobNextGen.setAppVolume(0.5);
|
|
113
109
|
admobNextGen.setAppMuted(true);
|
|
@@ -117,7 +113,8 @@ Add this to your `config.xml` to restore the plugin automatically.
|
|
|
117
113
|
// 1. Request Consent Information
|
|
118
114
|
admobNextGen.requestConsentInfo({
|
|
119
115
|
debug: false, // Set true for testing
|
|
120
|
-
reset: false
|
|
116
|
+
reset: false,
|
|
117
|
+
tagForUnderAgeOfConsent: false
|
|
121
118
|
}, function() {
|
|
122
119
|
console.log("Consent Info Ready.");
|
|
123
120
|
startSdk();
|
|
@@ -143,7 +140,11 @@ Add this to your `config.xml` to restore the plugin automatically.
|
|
|
143
140
|
|
|
144
141
|
// 3. Initialize the SDK
|
|
145
142
|
function startSdk() {
|
|
146
|
-
admobNextGen.initialize(
|
|
143
|
+
admobNextGen.initialize({
|
|
144
|
+
maxAdContentRating: 'G', // 'G' || 'PG' || 'T' || 'MA' || ""
|
|
145
|
+
tagForChildDirectedTreatment: false,
|
|
146
|
+
tagForUnderAgeOfConsent: false
|
|
147
|
+
}, function() {
|
|
147
148
|
console.log(">>> AdMob SDK Initialized & Ready <<<");
|
|
148
149
|
}, function(err) {
|
|
149
150
|
console.error("SDK Init Failed", err);
|
|
@@ -427,6 +428,7 @@ Supports Auto-Resume logic.
|
|
|
427
428
|
on.rewarded.failed.show (obj)
|
|
428
429
|
on.rewarded.revenue (obj)
|
|
429
430
|
on.rewarded.shown
|
|
431
|
+
on.rewarded.canceled
|
|
430
432
|
on.rewarded.dismissed
|
|
431
433
|
on.rewarded.failed.show (obj)
|
|
432
434
|
on.rewarded.impression
|
|
@@ -457,6 +459,7 @@ Auto-showing rewarded format (no opt-in).
|
|
|
457
459
|
on.rewardedInter.failed.show (obj)
|
|
458
460
|
on.rewardedInter.revenue (obj)
|
|
459
461
|
on.rewardedInter.shown
|
|
462
|
+
on.rewardedInter.canceled
|
|
460
463
|
on.rewardedInter.dismissed
|
|
461
464
|
on.rewardedInter.failed.show (obj)
|
|
462
465
|
on.rewardedInter.impression
|
|
@@ -44,7 +44,7 @@ function updateGradleDependencies(nextGenVersion, umpVersion) {
|
|
|
44
44
|
if (umpRegex.test(content)) content = content.replace(umpRegex, newUmp);
|
|
45
45
|
|
|
46
46
|
fs.writeFileSync(gradlePath, content, 'utf8');
|
|
47
|
-
console.log(`[AdMob Hook] Success: Updated Android Next Gen SDK to ${nextGenVersion} and UMP to ${umpVersion}`);
|
|
47
|
+
//console.log(`[AdMob Hook] Success: Updated Android Next Gen SDK to ${nextGenVersion} and UMP to ${umpVersion}`);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
function injectExclusionRules() {
|
|
@@ -62,7 +62,7 @@ function injectExclusionRules() {
|
|
|
62
62
|
`;
|
|
63
63
|
content += exclusionBlock;
|
|
64
64
|
fs.writeFileSync(gradlePath, content, 'utf8');
|
|
65
|
-
|
|
65
|
+
// console.log('[AdMob Hook] Success: Injected legacy SDK exclusion rules into build.gradle');
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/**
|
|
@@ -72,7 +72,7 @@ function injectExclusionRules() {
|
|
|
72
72
|
*/
|
|
73
73
|
function updateIosInfoPlist(appIdIos) {
|
|
74
74
|
if (!fs.existsSync(iosPlistPath)) {
|
|
75
|
-
console.warn('[AdMob Hook] Warning: ios/App/App/Info.plist not found. Run "npx cap add ios" first.');
|
|
75
|
+
//console.warn('[AdMob Hook] Warning: ios/App/App/Info.plist not found. Run "npx cap add ios" first.');
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -128,7 +128,7 @@ function updateIosInfoPlist(appIdIos) {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
fs.writeFileSync(iosPlistPath, content, 'utf8');
|
|
131
|
-
console.log(`[AdMob Hook] Success: Updated iOS Info.plist with App ID (${appIdIos}), ATT prompt, and SKAdNetworks.`);
|
|
131
|
+
// console.log(`[AdMob Hook] Success: Updated iOS Info.plist with App ID (${appIdIos}), ATT prompt, and SKAdNetworks.`);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
/**
|
|
@@ -139,7 +139,7 @@ function updateIosInfoPlist(appIdIos) {
|
|
|
139
139
|
function run() {
|
|
140
140
|
try {
|
|
141
141
|
if (!fs.existsSync(configPath)) {
|
|
142
|
-
console.warn('[AdMob Hook] capacitor.config not found. Skipping auto-injection.');
|
|
142
|
+
// console.warn('[AdMob Hook] capacitor.config not found. Skipping auto-injection.');
|
|
143
143
|
return;
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -158,7 +158,7 @@ function run() {
|
|
|
158
158
|
admob = {
|
|
159
159
|
APP_ID_ANDROID: appIdAndroid ? appIdAndroid[1] : "ca-app-pub-3940256099942544~3347511713",
|
|
160
160
|
APP_ID_IOS: appIdIos ? appIdIos[1] : "ca-app-pub-3940256099942544~1458002511",
|
|
161
|
-
NEXT_GEN_SDK_VERSION: sdk ? sdk[1] : "0.
|
|
161
|
+
NEXT_GEN_SDK_VERSION: sdk ? sdk[1] : "1.0.0",
|
|
162
162
|
UMP_VERSION: ump ? ump[1] : "4.0.0"
|
|
163
163
|
};
|
|
164
164
|
}
|
|
@@ -167,7 +167,7 @@ function run() {
|
|
|
167
167
|
injectExclusionRules();
|
|
168
168
|
if (admob?.NEXT_GEN_SDK_VERSION || admob?.UMP_VERSION) {
|
|
169
169
|
updateGradleDependencies(
|
|
170
|
-
admob.NEXT_GEN_SDK_VERSION || "0.
|
|
170
|
+
admob.NEXT_GEN_SDK_VERSION || "1.0.0",
|
|
171
171
|
admob.UMP_VERSION || "4.0.0"
|
|
172
172
|
);
|
|
173
173
|
}
|
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.0.
|
|
3
|
+
version="1.0.6"
|
|
4
4
|
xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
5
5
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
6
6
|
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
|
|
27
27
|
<config-file parent="/*" target="AndroidManifest.xml">
|
|
28
28
|
<uses-permission android:name="android.permission.INTERNET" />
|
|
29
|
-
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
30
29
|
</config-file>
|
|
31
30
|
|
|
32
31
|
<framework src="src/android/hooks/admob-nextgen.gradle" custom="true" type="gradleReference" />
|
|
@@ -47,7 +46,7 @@
|
|
|
47
46
|
|
|
48
47
|
</platform>
|
|
49
48
|
|
|
50
|
-
<preference name="NEXT_GEN_SDK_VERSION" default="0.
|
|
49
|
+
<preference name="NEXT_GEN_SDK_VERSION" default="1.0.0" />
|
|
51
50
|
<preference name="UMP_VERSION" default="4.0.0" />
|
|
52
51
|
<preference name="APP_ID_ANDROID" default="ca-app-pub-3940256099942544~3347511713" />
|
|
53
52
|
|
|
@@ -187,10 +187,6 @@ public class AppOpenAdExecutor {
|
|
|
187
187
|
errData.put("message", error.getMessage());
|
|
188
188
|
fireEvent("on.appopen.failed.show", errData);
|
|
189
189
|
} catch (JSONException e) {}
|
|
190
|
-
|
|
191
|
-
if (currentAdUnitId != null) {
|
|
192
|
-
loadAdInternal(currentAdUnitId, null);
|
|
193
|
-
}
|
|
194
190
|
}
|
|
195
191
|
|
|
196
192
|
@Override
|
|
@@ -35,6 +35,7 @@ public class RewardedExecutor {
|
|
|
35
35
|
|
|
36
36
|
private boolean isLoading = false;
|
|
37
37
|
private boolean isAutoShow = false;
|
|
38
|
+
private boolean isRewardEarned = false;
|
|
38
39
|
|
|
39
40
|
private long lastLoadTime = 0;
|
|
40
41
|
private long minLoadInterval = 5000;
|
|
@@ -145,6 +146,8 @@ public class RewardedExecutor {
|
|
|
145
146
|
|
|
146
147
|
activity.runOnUiThread(() -> {
|
|
147
148
|
|
|
149
|
+
isRewardEarned = false;
|
|
150
|
+
|
|
148
151
|
rewardedAd.setAdEventCallback(new RewardedAdEventCallback() {
|
|
149
152
|
|
|
150
153
|
@Override
|
|
@@ -172,6 +175,11 @@ public class RewardedExecutor {
|
|
|
172
175
|
|
|
173
176
|
rewardedAd = null;
|
|
174
177
|
isLoading = false;
|
|
178
|
+
|
|
179
|
+
if (!isRewardEarned) {
|
|
180
|
+
fireEvent("on.rewarded.canceled", null);
|
|
181
|
+
}
|
|
182
|
+
|
|
175
183
|
fireEvent("on.rewarded.dismissed", null);
|
|
176
184
|
}
|
|
177
185
|
|
|
@@ -202,6 +210,8 @@ public class RewardedExecutor {
|
|
|
202
210
|
@Override
|
|
203
211
|
public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
|
|
204
212
|
|
|
213
|
+
isRewardEarned = true;
|
|
214
|
+
|
|
205
215
|
try {
|
|
206
216
|
JSONObject rewardData = new JSONObject();
|
|
207
217
|
rewardData.put("amount", rewardItem.getAmount());
|
|
@@ -36,6 +36,7 @@ public class RewardedInterstitialExecutor {
|
|
|
36
36
|
private boolean isLoading = false;
|
|
37
37
|
private long lastLoadTime = 0;
|
|
38
38
|
private long minLoadInterval = 5000;
|
|
39
|
+
private boolean isRewardEarned = false;
|
|
39
40
|
|
|
40
41
|
public RewardedInterstitialExecutor(CordovaInterface cordova, CordovaWebView webView) {
|
|
41
42
|
this.cordova = cordova;
|
|
@@ -121,6 +122,8 @@ public class RewardedInterstitialExecutor {
|
|
|
121
122
|
cordova.getActivity().runOnUiThread(() -> {
|
|
122
123
|
if (mRewardedInterstitialAd != null) {
|
|
123
124
|
|
|
125
|
+
isRewardEarned = false;
|
|
126
|
+
|
|
124
127
|
mRewardedInterstitialAd.setAdEventCallback(new RewardedInterstitialAdEventCallback() {
|
|
125
128
|
|
|
126
129
|
@Override
|
|
@@ -146,6 +149,10 @@ public class RewardedInterstitialExecutor {
|
|
|
146
149
|
@Override
|
|
147
150
|
public void onAdDismissedFullScreenContent() {
|
|
148
151
|
|
|
152
|
+
if (!isRewardEarned) {
|
|
153
|
+
fireEvent("on.rewardedInter.canceled", null);
|
|
154
|
+
}
|
|
155
|
+
|
|
149
156
|
fireEvent("on.rewardedInter.dismissed", null);
|
|
150
157
|
mRewardedInterstitialAd = null;
|
|
151
158
|
}
|
|
@@ -176,6 +183,8 @@ public class RewardedInterstitialExecutor {
|
|
|
176
183
|
Activity activity = cordova.getActivity();
|
|
177
184
|
mRewardedInterstitialAd.show(activity, rewardItem -> {
|
|
178
185
|
|
|
186
|
+
isRewardEarned = true;
|
|
187
|
+
|
|
179
188
|
try {
|
|
180
189
|
JSONObject data = new JSONObject();
|
|
181
190
|
data.put("amount", rewardItem.getAmount());
|
|
@@ -191,10 +191,6 @@
|
|
|
191
191
|
self.appOpenAd = nil;
|
|
192
192
|
self.isShowingAd = NO;
|
|
193
193
|
[self.plugin fireEvent:@"document" event:@"on.appopen.dismissed" withData:nil];
|
|
194
|
-
|
|
195
|
-
if (self.currentAdUnitId) {
|
|
196
|
-
[self loadAdInternal:self.currentAdUnitId command:nil];
|
|
197
|
-
}
|
|
198
194
|
}
|
|
199
195
|
|
|
200
196
|
- (void)ad:(id<GADFullScreenPresentingAd>)ad didFailToPresentFullScreenContentWithError:(NSError *)error {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
@property (nonatomic, assign) BOOL isLoading;
|
|
10
10
|
@property (nonatomic, assign) BOOL isAutoShow;
|
|
11
|
+
@property (nonatomic, assign) BOOL isRewardEarned;
|
|
11
12
|
|
|
12
13
|
@property (nonatomic, assign) NSTimeInterval lastLoadTime;
|
|
13
14
|
@property (nonatomic, assign) NSTimeInterval minLoadInterval;
|
|
@@ -22,6 +23,7 @@
|
|
|
22
23
|
self.plugin = plugin;
|
|
23
24
|
self.isLoading = NO;
|
|
24
25
|
self.isAutoShow = NO;
|
|
26
|
+
self.isRewardEarned = NO;
|
|
25
27
|
self.lastLoadTime = 0;
|
|
26
28
|
self.minLoadInterval = 5.0;
|
|
27
29
|
}
|
|
@@ -128,9 +130,13 @@
|
|
|
128
130
|
- (void)showRewardedAd {
|
|
129
131
|
if (self.rewardedAd == nil) return;
|
|
130
132
|
|
|
133
|
+
self.isRewardEarned = NO;
|
|
134
|
+
|
|
131
135
|
[self.rewardedAd presentFromRootViewController:self.plugin.viewController
|
|
132
136
|
userDidEarnRewardHandler:^{
|
|
133
137
|
|
|
138
|
+
self.isRewardEarned = YES;
|
|
139
|
+
|
|
134
140
|
GADAdReward *reward = self.rewardedAd.adReward;
|
|
135
141
|
|
|
136
142
|
NSString *jsonStr = [NSString stringWithFormat:@"{\"amount\":%f, \"type\":\"%@\"}", [reward.amount doubleValue], reward.type];
|
|
@@ -155,6 +161,9 @@
|
|
|
155
161
|
|
|
156
162
|
- (void)adDidDismissFullScreenContent:(id<GADFullScreenPresentingAd>)ad {
|
|
157
163
|
|
|
164
|
+
if (!self.isRewardEarned) {
|
|
165
|
+
[self.plugin fireEvent:@"document" event:@"on.rewarded.canceled" withData:nil];
|
|
166
|
+
}
|
|
158
167
|
self.rewardedAd = nil;
|
|
159
168
|
self.isLoading = NO;
|
|
160
169
|
[self.plugin fireEvent:@"document" event:@"on.rewarded.dismissed" withData:nil];
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
@property (nonatomic, assign) BOOL isLoading;
|
|
10
10
|
@property (nonatomic, assign) BOOL isAutoShow;
|
|
11
|
+
@property (nonatomic, assign) BOOL isRewardEarned;
|
|
11
12
|
|
|
12
13
|
@property (nonatomic, assign) NSTimeInterval lastLoadTime;
|
|
13
14
|
@property (nonatomic, assign) NSTimeInterval minLoadInterval;
|
|
@@ -22,6 +23,7 @@
|
|
|
22
23
|
self.plugin = plugin;
|
|
23
24
|
self.isLoading = NO;
|
|
24
25
|
self.isAutoShow = NO;
|
|
26
|
+
self.isRewardEarned = NO;
|
|
25
27
|
self.lastLoadTime = 0;
|
|
26
28
|
self.minLoadInterval = 5.0;
|
|
27
29
|
}
|
|
@@ -143,9 +145,13 @@
|
|
|
143
145
|
- (void)showRewardedInterstitialAd:(CDVInvokedUrlCommand *)command {
|
|
144
146
|
if (self.rewardedInterstitialAd != nil) {
|
|
145
147
|
|
|
148
|
+
self.isRewardEarned = NO;
|
|
149
|
+
|
|
146
150
|
[self.rewardedInterstitialAd presentFromRootViewController:self.plugin.viewController
|
|
147
151
|
userDidEarnRewardHandler:^{
|
|
148
152
|
|
|
153
|
+
self.isRewardEarned = YES;
|
|
154
|
+
|
|
149
155
|
GADAdReward *reward = self.rewardedInterstitialAd.adReward;
|
|
150
156
|
|
|
151
157
|
NSString *jsonStr = [NSString stringWithFormat:@"{\"amount\":%f, \"type\":\"%@\"}", [reward.amount doubleValue], reward.type];
|
|
@@ -182,6 +188,9 @@
|
|
|
182
188
|
|
|
183
189
|
- (void)adDidDismissFullScreenContent:(id<GADFullScreenPresentingAd>)ad {
|
|
184
190
|
|
|
191
|
+
if (!self.isRewardEarned) {
|
|
192
|
+
[self.plugin fireEvent:@"document" event:@"on.rewardedInter.canceled" withData:nil];
|
|
193
|
+
}
|
|
185
194
|
self.rewardedInterstitialAd = nil;
|
|
186
195
|
self.isLoading = NO;
|
|
187
196
|
[self.plugin fireEvent:@"document" event:@"on.rewardedInter.dismissed" withData:nil];
|