cordova-plugin-admob-nextgen 1.0.4 → 1.0.5

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 CHANGED
@@ -102,12 +102,6 @@ Add this to your `config.xml` to restore the plugin automatically.
102
102
 
103
103
  ### Step 1: Global Configuration (Run First)
104
104
 
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
105
  // Optional: Mute ads globally
112
106
  admobNextGen.setAppVolume(0.5);
113
107
  admobNextGen.setAppMuted(true);
@@ -117,7 +111,8 @@ Add this to your `config.xml` to restore the plugin automatically.
117
111
  // 1. Request Consent Information
118
112
  admobNextGen.requestConsentInfo({
119
113
  debug: false, // Set true for testing
120
- reset: false
114
+ reset: false,
115
+ tagForUnderAgeOfConsent: false
121
116
  }, function() {
122
117
  console.log("Consent Info Ready.");
123
118
  startSdk();
@@ -143,7 +138,11 @@ Add this to your `config.xml` to restore the plugin automatically.
143
138
 
144
139
  // 3. Initialize the SDK
145
140
  function startSdk() {
146
- admobNextGen.initialize(function() {
141
+ admobNextGen.initialize({
142
+ maxAdContentRating: 'G', // 'G' || 'PG' || 'T' || 'MA' || ""
143
+ tagForChildDirectedTreatment: false,
144
+ tagForUnderAgeOfConsent: false
145
+ }, function() {
147
146
  console.log(">>> AdMob SDK Initialized & Ready <<<");
148
147
  }, function(err) {
149
148
  console.error("SDK Init Failed", err);
@@ -427,6 +426,7 @@ Supports Auto-Resume logic.
427
426
  on.rewarded.failed.show (obj)
428
427
  on.rewarded.revenue (obj)
429
428
  on.rewarded.shown
429
+ on.rewarded.canceled
430
430
  on.rewarded.dismissed
431
431
  on.rewarded.failed.show (obj)
432
432
  on.rewarded.impression
@@ -457,6 +457,7 @@ Auto-showing rewarded format (no opt-in).
457
457
  on.rewardedInter.failed.show (obj)
458
458
  on.rewardedInter.revenue (obj)
459
459
  on.rewardedInter.shown
460
+ on.rewardedInter.canceled
460
461
  on.rewardedInter.dismissed
461
462
  on.rewardedInter.failed.show (obj)
462
463
  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
- console.log('[AdMob Hook] Success: Injected legacy SDK exclusion rules into build.gradle');
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.25.0-beta01",
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.25.0-beta01",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-admob-nextgen",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Google Mobile Ads Next Gen SDK for Cordova. High performance and modular architecture. ",
5
5
  "cordova": {
6
6
  "id": "cordova-plugin-admob-nextgen",
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.4"
3
+ version="1.0.5"
4
4
  xmlns="http://apache.org/cordova/ns/plugins/1.0"
5
5
  xmlns:android="http://schemas.android.com/apk/res/android">
6
6
 
@@ -47,7 +47,7 @@
47
47
 
48
48
  </platform>
49
49
 
50
- <preference name="NEXT_GEN_SDK_VERSION" default="0.25.0-beta01" />
50
+ <preference name="NEXT_GEN_SDK_VERSION" default="1.0.0" />
51
51
  <preference name="UMP_VERSION" default="4.0.0" />
52
52
  <preference name="APP_ID_ANDROID" default="ca-app-pub-3940256099942544~3347511713" />
53
53
 
@@ -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());
@@ -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];