emi-indo-cordova-plugin-admob 1.5.5 → 1.5.7

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
@@ -12,7 +12,8 @@
12
12
  ### IAB Europe Transparency & Consent Framework (CPM: 2.2.0)
13
13
 
14
14
 
15
- ## New example https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/tree/main/example/www
15
+ ## New example
16
+ - https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/tree/main/example/www
16
17
 
17
18
 
18
19
  ## Minimum Cordova Engines
@@ -142,7 +143,8 @@ cordova plugin rm emi-indo-cordova-plugin-admob
142
143
 
143
144
  ## Import the Mobile Ads SDK IOS
144
145
  ### Then from the command line run:
145
- - cd platforms/ios
146
+ - cd platforms/ios
147
+ - Then run cordova prepare
146
148
  ### Then from the command line run:
147
149
  - pod install --repo-update
148
150
 
@@ -284,103 +286,6 @@ document.addEventListener('on.TCString.expired', () => {
284
286
 
285
287
 
286
288
 
287
- ## Global Variable adunitId
288
-
289
- ```
290
- <script>
291
- Ad format Demo ad unit ID
292
- // https://developers.google.com/admob/android/test-ads
293
- // https://developers.google.com/admob/ios/test-ads
294
-
295
- var App_Open_ID;
296
- var Banner_ID;
297
- var Interstitial_ID;
298
- var Rewarded_ID;
299
- var Rewarded_Interstitial_ID;
300
-
301
- /* https://support.google.com/admob/answer/9493252?hl=en
302
- Best practice when using ad original ID unit,
303
- the app must be uploaded to the play store or app store,
304
- and you must upload it from there,
305
- otherwise you may be subject to ad serving restrictions,
306
- if it happens often, it is possible that your admob account will be permanently disabled.
307
- */
308
-
309
- if (window.cordova.platformId === 'ios') {
310
-
311
- App_Open_ID = 'ca-app-pub-3940256099942544/5575463023';
312
- Banner_ID = 'ca-app-pub-3940256099942544/2934735716';
313
- Interstitial_ID = 'ca-app-pub-3940256099942544/4411468910';
314
- Rewarded_ID = 'ca-app-pub-3940256099942544/1712485313';
315
- Rewarded_Interstitial_ID = 'ca-app-pub-3940256099942544/6978759866';
316
-
317
- } else {
318
- // Assume Android
319
- App_Open_ID = 'ca-app-pub-3940256099942544/9257395921';
320
- Banner_ID = 'ca-app-pub-3940256099942544/6300978111';
321
- Interstitial_ID = 'ca-app-pub-3940256099942544/1033173712';
322
- Rewarded_ID = 'ca-app-pub-3940256099942544/5224354917';
323
- Rewarded_Interstitial_ID = 'ca-app-pub-3940256099942544/5354046379';
324
- }
325
-
326
-
327
- cordova.plugins.emiAdmobPlugin.initialize({
328
- isUsingAdManagerRequest: true, // true = AdManagerAdRequest.Builder | false = AdRequest.Builder (Default true)
329
- isResponseInfo: true, // Default false
330
- isConsentDebug: true, // Default false
331
- });
332
-
333
-
334
- document.addEventListener('on.sdkInitialization', (data) => {
335
- // JSON.stringify(data)
336
- const sdkVersion = data.version;
337
- // const adAdapter = data.adapters;
338
- // const conStatus = data.consentStatus;
339
- // const gdprApplie = data.gdprApplies;
340
- // const purposeConsent = data.purposeConsents;
341
- // const vendorConsents = data.vendorConsents;
342
- // const conTCString = data.consentTCString;
343
- // const additionalConsent = data.additionalConsent;
344
- console.log("On Sdk Initialization version: " + sdkVersion);
345
-
346
-
347
- cordova.plugins.emiAdmobPlugin.loadInterstitialAd({
348
- adUnitId: "ca-app-pub-3940256099942544/1033173712",
349
- autoShow: true
350
- });
351
-
352
- });
353
-
354
-
355
- document.addEventListener('on.interstitial.loaded', () => {
356
-
357
- console.log("on interstitial Ad loaded");
358
-
359
- });
360
-
361
- // all events that contain the keyword dismissed there is a block to load the ad after it is closed by the user.
362
- // 'on.interstitial.dismissed' | 'on.rewardedInt.dismissed' | 'on.rewarded.dismissed'
363
- document.addEventListener('on.interstitial.dismissed', () => {
364
-
365
- console.log("on interstitial Ad dismissed");
366
- console.log("you can load ads automatically after the ads are closed by users");
367
- // loadInterstitialAd();
368
-
369
- });
370
-
371
- function loadInterstitialAd(){
372
-
373
- cordova.plugins.emiAdmobPlugin.loadInterstitialAd({
374
- adUnitId: "ca-app-pub-3940256099942544/1033173712",
375
- autoShow: false
376
- });
377
-
378
- }
379
-
380
-
381
- </script>
382
- ```
383
-
384
289
 
385
290
  ## AppOpenAd ADS
386
291
 
@@ -428,7 +333,7 @@ document.addEventListener('on.appOpenAd.loaded', () => {
428
333
  </pre>
429
334
  </details>
430
335
 
431
- - [FULL AppOpenAd basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/Example/www/js/appOpenAd.js)
336
+ - [FULL AppOpenAd basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/appOpenAd.js)
432
337
 
433
338
 
434
339
 
@@ -531,7 +436,7 @@ console.log("Collapsible Status: " + event.collapsible);
531
436
  </pre>
532
437
  </details>
533
438
 
534
- [FULL Banner basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/Example/www/js/bannerAd.js)
439
+ [FULL Banner basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/bannerAd.js)
535
440
 
536
441
 
537
442
  ## Interstitial ADS
@@ -594,7 +499,7 @@ document.addEventListener('on.interstitial.dismissed', () => {
594
499
  </details>
595
500
 
596
501
 
597
- [FULL Interstitial basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/Example/www/js/interstitialAd.js)
502
+ [FULL Interstitial basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/interstitialAd.js)
598
503
 
599
504
 
600
505
 
@@ -723,7 +628,7 @@ document.addEventListener('on.rewarded.dismissed', () => {
723
628
  </pre>
724
629
  </details>
725
630
 
726
- [FULL Rewarded basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/Example/www/js/rewardedAd.js)
631
+ [FULL Rewarded basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/rewardedAd.js)
727
632
 
728
633
 
729
634
 
@@ -1005,7 +910,7 @@ on.orientation.landscape
1005
910
 
1006
911
 
1007
912
 
1008
- # Admob Mediation
913
+ # Admob Mediation (supports both platforms)
1009
914
 
1010
915
  <details>
1011
916
  <summary>Mediation #9</summary>
@@ -1017,7 +922,7 @@ on.orientation.landscape
1017
922
 
1018
923
  ## get Mediation Adapter Name
1019
924
 
1020
- responseInfo = true // (debugging)
925
+ isResponseInfo: true, // debug Default false // (debugging)
1021
926
 
1022
927
  <img src="https://user-images.githubusercontent.com/78555833/230655800-0dbc3f12-72fb-4cf3-b4e6-801704fade28.png" width="250">
1023
928
 
@@ -1101,24 +1006,25 @@ cordova plugin add emi-indo-cordova-plugin-mediation-ironsource
1101
1006
 
1102
1007
  - Cordova CLI Update Adapter version with Variables
1103
1008
  ```sh
1104
- cordova plugin add emi-indo-cordova-plugin-mediation-meta --variable META_ADAPTER_VERSION="xxxxx"
1009
+ cordova plugin add emi-indo-cordova-plugin-mediation-meta --save --variable META_ADAPTER_VERSION="xxxxx" --variable IOS_META_ADAPTER_VERSION="xxxxx"
1105
1010
  ```
1106
1011
  - Update Adapter version with config.xml
1107
1012
  ```sh
1108
1013
  <preference name="META_ADAPTER_VERSION" value="xxxxx" />
1014
+ <preference name="IOS_META_ADAPTER_VERSION" value="xxxxx" />
1109
1015
  ```
1110
1016
 
1111
1017
  ### Variables Name
1112
1018
 
1113
- - --variable META_ADAPTER_VERSION="xxxxx"
1114
- - --variable UNITY_ADAPTER_VERSION="xxxxx"
1115
- - --variable APPLOVIN_ADAPTER_VERSION="xxxxx"
1116
- - --variable ADCOLONY_ADAPTER_VERSION="xxxxx"
1117
- - --variable CHARTBOOST_ADAPTER_VERSION="xxxxx"
1118
- - --variable IRONSOURCE_ADAPTER_VERSION="xxxxx"
1019
+ - --variable META_ADAPTER_VERSION="xxxxx" --variable IOS_META_ADAPTER_VERSION="xxxxx"
1020
+ - --variable UNITY_ADAPTER_VERSION="xxxxx" --variable IOS_UNITY_ADAPTER_VERSION="xxxxx"
1021
+ - --variable APPLOVIN_ADAPTER_VERSION="xxxxx" --variable IOS_APPLOVIN_ADAPTER_VERSION="xxxxx"
1022
+ - --variable ADCOLONY_ADAPTER_VERSION="xxxxx" --variable IOS_ADCOLONY_ADAPTER_VERSION="xxxxx"
1023
+ - --variable CHARTBOOST_ADAPTER_VERSION="xxxxx" --variable IOS_CHARTBOOST_ADAPTER_VERSION="xxxxx"
1024
+ - --variable IRONSOURCE_ADAPTER_VERSION="xxxxx" --variable IOS_IRONSOURCE_ADAPTER_VERSION="xxxxx"
1119
1025
 
1120
1026
  ### preference name
1121
-
1027
+ ## (ANDROID)
1122
1028
  - META_ADAPTER_VERSION
1123
1029
  - UNITY_ADAPTER_VERSION
1124
1030
  - APPLOVIN_ADAPTER_VERSION
@@ -1126,6 +1032,14 @@ cordova plugin add emi-indo-cordova-plugin-mediation-meta --variable META_ADAPTE
1126
1032
  - CHARTBOOST_ADAPTER_VERSION
1127
1033
  - IRONSOURCE_ADAPTER_VERSION
1128
1034
 
1035
+ ## (IOS)
1036
+ - IOS_META_ADAPTER_VERSION
1037
+ - IOS_UNITY_ADAPTER_VERSION
1038
+ - IOS_APPLOVIN_ADAPTER_VERSION
1039
+ - IOS_ADCOLONY_ADAPTER_VERSION
1040
+ - IOS_CHARTBOOST_ADAPTER_VERSION
1041
+ - IOS_IRONSOURCE_ADAPTER_VERSION
1042
+
1129
1043
  - ================================
1130
1044
  </details>
1131
1045
 
@@ -1,14 +1,15 @@
1
1
  <html>
2
2
  <head>
3
3
  <script type="text/javascript" src="cordova.js"></script>
4
+ <script src="js/deviceready.js" defer></script>
4
5
  <script src="js/appOpenAd.js" defer></script>
5
6
  <script src="js/bannerAd.js" defer></script>
6
7
  <script src="js/interstitialAd.js" defer></script>
7
8
  <script src="js/rewardedAd.js" defer></script>
8
- <script src="js/deviceready.js" defer></script>
9
9
  </head>
10
10
  <body>
11
11
 
12
+
12
13
  <label for="event">Debug Event All response :</label>
13
14
  <textarea id="log" name="log" rows="5" cols="40"></textarea>
14
15
 
@@ -62,7 +62,6 @@ on.appOpenAd.responseInfo
62
62
  */
63
63
 
64
64
 
65
-
66
65
  document.addEventListener('on.appOpenAd.loaded', () => {
67
66
  isAppOpenAdLoad = true;
68
67
  console.log("on.appOpenAd.loaded");
@@ -1,4 +1,4 @@
1
- // cordova.plugins.emiAdmobPlugin.styleBannerAd({ padding: 50, margins: 50 }); // (Optional only android)
1
+ // ccordova.plugins.emiAdmobPlugin.styleBannerAd({isOverlapping: true, overlappingHeight: 5, padding: 0, margins: 0 }); // ( only android)
2
2
  //cordova.plugins.emiAdmobPlugin.loadBannerAd({config});
3
3
  //cordova.plugins.emiAdmobPlugin.showBannerAd(); // default
4
4
  //cordova.plugins.emiAdmobPlugin.hideBannerAd(); // default
@@ -10,6 +10,13 @@ function loadBanner() {
10
10
 
11
11
  if (typeof cordova !== 'undefined') {
12
12
 
13
+ cordova.plugins.emiAdmobPlugin.styleBannerAd({
14
+ isOverlapping: true,
15
+ overlappingHeight: 5,
16
+ padding: 0,
17
+ margins: 0
18
+ });
19
+
13
20
  cordova.plugins.emiAdmobPlugin.loadBannerAd({
14
21
  adUnitId: Banner_ID, //Banner_ID,
15
22
  position: "bottom-center",
@@ -27,7 +34,6 @@ function loadBanner() {
27
34
 
28
35
 
29
36
 
30
-
31
37
  /* ///////<<<< bannerAd position >>>>>>\\\\\\\
32
38
 
33
39
  (ANDROID)
@@ -21,6 +21,7 @@ if it happens often, it is possible that your admob account will be permanently
21
21
  */
22
22
 
23
23
 
24
+
24
25
  if (window.cordova.platformId === 'ios') {
25
26
 
26
27
  App_Open_ID = 'ca-app-pub-3940256099942544/5575463023';
@@ -41,7 +41,6 @@ on.interstitialAd.responseInfo
41
41
  */
42
42
 
43
43
 
44
-
45
44
  // EVENT For example
46
45
 
47
46
  document.addEventListener('on.interstitial.loaded', () => {
@@ -20,6 +20,7 @@ function showRewarded() {
20
20
 
21
21
  }
22
22
 
23
+
23
24
  /*
24
25
  on.rewarded.loaded
25
26
  on.rewarded.failed.load
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emi-indo-cordova-plugin-admob",
3
- "version": "1.5.5",
3
+ "version": "1.5.7",
4
4
  "description": "Cordova Plugin Admob Android IOS",
5
5
  "cordova": {
6
6
  "id": "emi-indo-cordova-plugin-admob",
package/plugin.xml CHANGED
@@ -1,6 +1,6 @@
1
1
  <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
2
2
  xmlns:android="http://schemas.android.com/apk/res/android"
3
- id="emi-indo-cordova-plugin-admob" version="1.5.5">
3
+ id="emi-indo-cordova-plugin-admob" version="1.5.7">
4
4
 
5
5
  <name>emiAdmobPlugin</name>
6
6
  <description>Cordova Plugin Admob Android IOS</description>
@@ -86,12 +86,17 @@ class emiAdmobPlugin : CordovaPlugin() {
86
86
 
87
87
  private var consentInformation: ConsentInformation? = null
88
88
 
89
+ private var isOverlapping: Boolean = false
90
+ private var overlappingHeight: Int = 0
91
+
89
92
  var isBannerLoad: Boolean = false
90
93
  var isBannerShow: Boolean = false
91
94
 
92
95
  var isBannerShows: Boolean = true
93
96
  private var bannerAutoShow = false
94
97
  private var isAutoResize: Boolean = false
98
+
99
+
95
100
  var appOpenAutoShow: Boolean = false
96
101
  var intAutoShow: Boolean = false
97
102
  var rewardedAutoShow: Boolean = false
@@ -1077,13 +1082,15 @@ class emiAdmobPlugin : CordovaPlugin() {
1077
1082
  val options = args.getJSONObject(0)
1078
1083
  if(mActivity != null) {
1079
1084
  mActivity!!.runOnUiThread {
1085
+ val isOverlapping = options.optBoolean("isOverlapping")
1086
+ val overlappingHeight = options.optInt("overlappingHeight")
1080
1087
  val paddingPx = options.optInt("padding")
1081
1088
  val marginsPx = options.optInt("margins")
1082
- // final boolean autoResize = options.optBoolean("autoResize");
1083
1089
  try {
1090
+ this.isOverlapping = isOverlapping
1091
+ this.overlappingHeight = overlappingHeight
1084
1092
  this.paddingInPx = paddingPx
1085
1093
  this.marginsInPx = marginsPx
1086
- // this.isAutoResize = autoResize;
1087
1094
  } catch (e: Exception) {
1088
1095
  callbackContext.error(e.toString())
1089
1096
  }
@@ -1192,7 +1199,7 @@ class emiAdmobPlugin : CordovaPlugin() {
1192
1199
  bannerView!!.adUnitId = adUnitId
1193
1200
  bannerView!!.adListener = bannerAdListener
1194
1201
  bannerView!!.loadAd(buildAdRequest())
1195
- adjustWebViewForBanner(position)
1202
+ // adjustWebViewForBanner(position)
1196
1203
  } else {
1197
1204
  Log.d(TAG, "Banner view layout already exists.")
1198
1205
  }
@@ -1369,6 +1376,11 @@ class emiAdmobPlugin : CordovaPlugin() {
1369
1376
  if (bannerAutoShow) {
1370
1377
  isBannerAutoShow()
1371
1378
  }
1379
+
1380
+ if (isOverlapping) {
1381
+ bannerOverlapping()
1382
+ }
1383
+
1372
1384
  cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.load');")
1373
1385
 
1374
1386
  val eventData = String.format(
@@ -1412,6 +1424,32 @@ class emiAdmobPlugin : CordovaPlugin() {
1412
1424
  }
1413
1425
 
1414
1426
 
1427
+ // fix https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/issues/26
1428
+ private fun bannerOverlapping() {
1429
+ if (bannerView != null && mActivity != null && cWebView != null) {
1430
+ mActivity!!.runOnUiThread {
1431
+ try {
1432
+ val bannerHeightInPx = bannerView!!.height
1433
+ val displayMetrics = DisplayMetrics()
1434
+ mActivity!!.windowManager.defaultDisplay.getMetrics(displayMetrics)
1435
+ val screenHeightInPx = displayMetrics.heightPixels
1436
+
1437
+ // Adjust the WebView height to account for the banner ad
1438
+ val webViewHeight = screenHeightInPx - (adSize.height+overlappingHeight)
1439
+ val layoutParams = cWebView!!.view.layoutParams
1440
+ layoutParams.height = webViewHeight
1441
+ cWebView!!.view.layoutParams = layoutParams
1442
+
1443
+ // Log for debugging
1444
+ Log.d("BannerAdjustment", "Adjusted WebView height: $webViewHeight")
1445
+ } catch (e: Exception) {
1446
+ Log.e("AdmobPlugin", "Error adjusting WebView for banner: ${e.message}")
1447
+ }
1448
+ }
1449
+ }
1450
+ }
1451
+
1452
+
1415
1453
  private val bannerPaidAdListener = OnPaidEventListener { adValue ->
1416
1454
  val valueMicros = adValue.valueMicros
1417
1455
  val currencyCode = adValue.currencyCode
@@ -17,10 +17,10 @@ int idfaStatus = 0;
17
17
  // int fromStatus = 0; // Deprecated
18
18
  int Consent_Status = 0;
19
19
  int adFormat = 0;
20
- int adWidth = 320; // Default
20
+ int adWidth = 320; // Deprecated
21
21
  BOOL auto_Show = NO;
22
22
  // NSString *Npa = @"1"; // Deprecated
23
- NSString *Position = @"bottom"; // Default
23
+ NSString *Position = @"bottom-center"; // Default
24
24
  NSString *bannerSaveAdUnitId = @""; // autoResize dependency = true
25
25
 
26
26
  BOOL enableCollapsible = NO;
@@ -1163,8 +1163,8 @@ BOOL isUsingAdManagerRequest = YES;
1163
1163
 
1164
1164
  // Prepare reward data as JSON
1165
1165
  NSDictionary *rewardData = @{
1166
- @"currency": reward.type,
1167
- @"amount": [reward.amount stringValue]
1166
+ @"rewardType": reward.type,
1167
+ @"rewardAmount": [reward.amount stringValue]
1168
1168
  };
1169
1169
  NSData *rewardJsonData = [NSJSONSerialization dataWithJSONObject:rewardData options:0 error:nil];
1170
1170
  NSString *rewardJsonString = [[NSString alloc] initWithData:rewardJsonData encoding:NSUTF8StringEncoding];
@@ -1241,8 +1241,8 @@ BOOL isUsingAdManagerRequest = YES;
1241
1241
 
1242
1242
  // Prepare reward data as JSON
1243
1243
  NSDictionary *rewardData = @{
1244
- @"currency": reward.type,
1245
- @"amount": [reward.amount stringValue]
1244
+ @"rewardType": reward.type,
1245
+ @"rewardAmount": [reward.amount stringValue]
1246
1246
  };
1247
1247
  NSData *rewardJsonData = [NSJSONSerialization dataWithJSONObject:rewardData options:0 error:nil];
1248
1248
  NSString *rewardJsonString = [[NSString alloc] initWithData:rewardJsonData encoding:NSUTF8StringEncoding];
@@ -1329,8 +1329,8 @@ BOOL isUsingAdManagerRequest = YES;
1329
1329
  GADAdReward *reward = self.rewardedAd.adReward;
1330
1330
 
1331
1331
  NSDictionary *rewardData = @{
1332
- @"currency": reward.type,
1333
- @"amount": [reward.amount stringValue]
1332
+ @"rewardType": reward.type,
1333
+ @"rewardAmount": [reward.amount stringValue]
1334
1334
  };
1335
1335
  NSData *rewardJsonData = [NSJSONSerialization dataWithJSONObject:rewardData options:0 error:nil];
1336
1336
  NSString *rewardJsonString = [[NSString alloc] initWithData:rewardJsonData encoding:NSUTF8StringEncoding];
@@ -1402,8 +1402,8 @@ BOOL isUsingAdManagerRequest = YES;
1402
1402
  GADAdReward *reward = self.rewardedAd.adReward;
1403
1403
 
1404
1404
  NSDictionary *rewardData = @{
1405
- @"currency": reward.type,
1406
- @"amount": [reward.amount stringValue]
1405
+ @"rewardType": reward.type,
1406
+ @"rewardAmount": [reward.amount stringValue]
1407
1407
  };
1408
1408
  NSError *jsonError;
1409
1409
  NSData *jsonData = [NSJSONSerialization dataWithJSONObject:rewardData options:0 error:&jsonError];