emi-indo-cordova-plugin-admob 2.0.9 → 2.2.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 CHANGED
@@ -1,4 +1,4 @@
1
- ### emi-indo-cordova-plugin-admob@2.0.9
1
+ ### emi-indo-cordova-plugin-admob@2.2.9
2
2
 
3
3
 
4
4
  ## Features/method
@@ -156,7 +156,7 @@ config.xml
156
156
  ### Check all release notes: https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/
157
157
 
158
158
 
159
- ### Mobile Ads SDK (Android: 24.1.0) [Release Notes:](https://developers.google.com/admob/android/rel-notes)
159
+ ### Mobile Ads SDK (Android: 24.2.0) [Release Notes:](https://developers.google.com/admob/android/rel-notes)
160
160
  ### User Messaging Platform (UMP Android: 3.2.0) [Release Notes:](https://developers.google.com/admob/android/privacy/release-notes)
161
161
 
162
162
  ### Mobile Ads SDK (IOS: 12.2.0) [Release Notes:](https://developers.google.com/admob/ios/rel-notes)
@@ -14,7 +14,7 @@
14
14
  "author": "Apache Cordova Team",
15
15
  "license": "Apache-2.0",
16
16
  "devDependencies": {
17
- "emi-indo-cordova-plugin-admob": "^2.0.8"
17
+ "emi-indo-cordova-plugin-admob": "^2.2.9"
18
18
  },
19
19
  "cordova": {
20
20
  "plugins": {
@@ -8,17 +8,7 @@
8
8
 
9
9
  function loadBanner() {
10
10
 
11
- // Optional Only IOS
12
- if (isPlatformIOS){
13
- cordova.plugins.emiAdmobPlugin.styleBannerAd({
14
- isOverlapping: true, // default false
15
- paddingWebView: 1.0
16
- });
17
-
18
- }
19
-
20
-
21
-
11
+ // default: Android | IOS
22
12
  cordova.plugins.emiAdmobPlugin.loadBannerAd({
23
13
  adUnitId: Banner_ID, //Banner_ID,
24
14
  position: "bottom-center", // bottom-center | top-center
@@ -30,6 +20,25 @@ function loadBanner() {
30
20
  });
31
21
 
32
22
 
23
+
24
+
25
+
26
+ // NOTE: Do not use loadBannerAd and loadBannerCapacitor together.
27
+
28
+ /*
29
+ // Only Android
30
+ cordova.plugins.emiAdmobPlugin.loadBannerCapacitor({
31
+ adUnitId: Banner_ID, //Banner_ID,
32
+ position: "bottom-center", // bottom-center | top-center
33
+ size: "banner",
34
+ collapsible: "", // position: top | bottom (disable, empty string)
35
+ autoShow: true, // default false
36
+ isOverlapping: false // The height of the body is reduced by the height of the banner.
37
+ // isOverlapping: true // The body height is not reduced, the banner overlaps on top of the body
38
+ });
39
+ */
40
+
41
+
33
42
  }
34
43
 
35
44
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emi-indo-cordova-plugin-admob",
3
- "version": "2.0.9",
3
+ "version": "2.2.9",
4
4
  "description": "Cordova/Quasar/Capacitor 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="2.0.9">
3
+ id="emi-indo-cordova-plugin-admob" version="2.2.9">
4
4
 
5
5
  <name>emiAdmobPlugin</name>
6
6
  <description>Cordova/Quasar/Capacitor Plugin Admob Android IOS</description>
@@ -59,7 +59,7 @@
59
59
  <!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
60
60
 
61
61
  <preference name="APP_ID_ANDROID" default="ca-app-pub-3940256099942544~3347511713" />
62
- <preference name="PLAY_SERVICES_VERSION" default="24.1.0" />
62
+ <preference name="PLAY_SERVICES_VERSION" default="24.2.0" />
63
63
 
64
64
  <framework src="com.google.android.gms:play-services-ads:$PLAY_SERVICES_VERSION" />
65
65
 
@@ -76,8 +76,6 @@
76
76
  <activity android:resizeableActivity="$MULTI_WINDOW" />
77
77
  </edit-config>
78
78
 
79
-
80
-
81
79
  <config-file parent="/*" target="AndroidManifest.xml" />
82
80
  <source-file src="src/android/emiAdmobPlugin.kt" target-dir="app/src/main/kotlin/emi/indo/cordova/plugin/admob" />
83
81
 
@@ -152,7 +152,8 @@ class emiAdmobPlugin : CordovaPlugin() {
152
152
 
153
153
 
154
154
  private var isFullScreen: Boolean = false
155
- // private var bannerOverlapping: Boolean = false
155
+ private var loadBannerCapacitor: Boolean = false
156
+ private var loadBannerCordova: Boolean = false
156
157
 
157
158
  override fun pluginInitialize() {
158
159
  super.pluginInitialize()
@@ -1030,7 +1031,7 @@ class emiAdmobPlugin : CordovaPlugin() {
1030
1031
  val collapsible = options.optString("collapsible")
1031
1032
  val size = options.optString("size")
1032
1033
  val autoShow = options.optBoolean("autoShow")
1033
- val isOverlapping = options.optBoolean("isOverlapping", false)
1034
+ val isOverlapping = options.optBoolean("isOverlapping")
1034
1035
  val paddingPx = options.optInt("padding")
1035
1036
  this.bannerAdUnitId = adUnitId
1036
1037
  this.isPosition = position
@@ -1039,6 +1040,34 @@ class emiAdmobPlugin : CordovaPlugin() {
1039
1040
  this.collapsiblePos = collapsible
1040
1041
  this.isOverlapping = isOverlapping
1041
1042
  this.paddingInPx = paddingPx
1043
+ this.loadBannerCordova = true
1044
+
1045
+ try {
1046
+ loadBannerAd(adUnitId, position, size)
1047
+ } catch (e: Exception) {
1048
+ callbackContext.error("loadBannerAd Error: " + e.message)
1049
+ }
1050
+ }
1051
+ }
1052
+ return true
1053
+
1054
+ } else if (action == "loadBannerCapacitor") {
1055
+ if (mActivity != null) {
1056
+ val options = args.getJSONObject(0)
1057
+ mActivity?.runOnUiThread {
1058
+ val adUnitId = options.optString("adUnitId")
1059
+ val position = options.optString("position")
1060
+ val collapsible = options.optString("collapsible")
1061
+ val size = options.optString("size")
1062
+ val autoShow = options.optBoolean("autoShow")
1063
+ val isOverlapping = options.optBoolean("isOverlapping")
1064
+ this.bannerAdUnitId = adUnitId
1065
+ this.isPosition = position
1066
+ this.isSize = size
1067
+ this.bannerAutoShow = autoShow
1068
+ this.collapsiblePos = collapsible
1069
+ this.isOverlapping = isOverlapping
1070
+ this.loadBannerCapacitor = true
1042
1071
 
1043
1072
  try {
1044
1073
  loadBannerAd(adUnitId, position, size)
@@ -1059,10 +1088,20 @@ class emiAdmobPlugin : CordovaPlugin() {
1059
1088
  bannerView?.visibility = View.VISIBLE
1060
1089
  bannerView?.resume()
1061
1090
 
1062
- if (isPosition == "top-center") {
1063
- setBannerAdTop()
1064
- } else {
1065
- setBannerAdBottom()
1091
+ if(loadBannerCordova) {
1092
+ if (isPosition == "top-center") {
1093
+ setBannerAdTop()
1094
+ } else {
1095
+ setBannerAdBottom()
1096
+ }
1097
+ }
1098
+
1099
+ if (loadBannerCapacitor) {
1100
+ if (isPosition == "top-center") {
1101
+ setBannerAdTopCapacitor()
1102
+ } else {
1103
+ setBannerAdBottomCapacitor()
1104
+ }
1066
1105
  }
1067
1106
 
1068
1107
  bannerViewLayout?.requestFocus()
@@ -1418,19 +1457,15 @@ class emiAdmobPlugin : CordovaPlugin() {
1418
1457
 
1419
1458
  cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.failed.load', ${errorData});")
1420
1459
 
1460
+
1421
1461
  if (bannerViewLayout != null && bannerView != null) {
1422
- /*
1423
- bannerViewLayout?.removeView(bannerView)
1424
- bannerView?.destroy()
1425
- bannerView = null
1426
- bannerViewLayout = null
1427
- */
1428
1462
  isBannerLoad = false
1429
- //isBannerShow = false
1430
1463
  isBannerPause = 2
1431
1464
  lock = true
1432
1465
  }
1433
1466
 
1467
+
1468
+
1434
1469
  }
1435
1470
 
1436
1471
  override fun onAdImpression() {
@@ -1454,10 +1489,20 @@ class emiAdmobPlugin : CordovaPlugin() {
1454
1489
  bannerViewHeight = heightInPx ?: 0
1455
1490
  }
1456
1491
 
1457
- if (isPosition == "top-center") {
1458
- setBannerAdTop()
1459
- } else {
1460
- setBannerAdBottom()
1492
+ if(loadBannerCordova) {
1493
+ if (isPosition == "top-center") {
1494
+ setBannerAdTop()
1495
+ } else {
1496
+ setBannerAdBottom()
1497
+ }
1498
+ }
1499
+
1500
+ if (loadBannerCapacitor) {
1501
+ if (isPosition == "top-center") {
1502
+ setBannerAdTopCapacitor()
1503
+ } else {
1504
+ setBannerAdBottomCapacitor()
1505
+ }
1461
1506
  }
1462
1507
 
1463
1508
  if (bannerAutoShow) {
@@ -1592,6 +1637,8 @@ class emiAdmobPlugin : CordovaPlugin() {
1592
1637
  }
1593
1638
 
1594
1639
 
1640
+
1641
+
1595
1642
  private fun setBannerAdTop() {
1596
1643
  mActivity?.let { activity ->
1597
1644
  bannerView?.post {
@@ -1641,6 +1688,174 @@ class emiAdmobPlugin : CordovaPlugin() {
1641
1688
 
1642
1689
 
1643
1690
 
1691
+
1692
+
1693
+
1694
+ private fun setBannerAdBottomCapacitor() {
1695
+ if (bannerView != null && mActivity != null && cWebView != null) {
1696
+ mActivity?.runOnUiThread {
1697
+ bannerView?.post {
1698
+ try {
1699
+ val measuredBannerHeight = if (bannerView!!.height > 0)
1700
+ bannerView!!.height //167
1701
+
1702
+ //adSize.height
1703
+ else
1704
+ adSize.getHeightInPixels(mActivity!!)
1705
+
1706
+ //61
1707
+
1708
+ val screenHeightInPx = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { //2186
1709
+
1710
+
1711
+ val windowMetrics = mActivity!!.windowManager.currentWindowMetrics //WindowMetrics:{bounds=Rect(0, 0 - 1080, 2400), windowInsets=null, density=2.75}
1712
+ val insets = windowMetrics.windowInsets.getInsets(WindowInsets.Type.systemBars()) //Insets{left=0, top=84, right=0, bottom=130}
1713
+ val height = windowMetrics.bounds.height() - insets.top - insets.bottom //2186 2400 - 84 - 130
1714
+ height
1715
+ } else {
1716
+ val displayMetrics = DisplayMetrics()
1717
+ @Suppress("DEPRECATION")
1718
+ mActivity!!.windowManager.defaultDisplay.getMetrics(displayMetrics)
1719
+ displayMetrics.heightPixels
1720
+ }
1721
+
1722
+ val webViewHeight = screenHeightInPx// - measuredBannerHeight //2186 - 167
1723
+
1724
+ if (!isFullScreen) {
1725
+ var navBarHeight = 0
1726
+
1727
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
1728
+ val windowMetrics = mActivity!!.windowManager.currentWindowMetrics
1729
+ val insets = windowMetrics.windowInsets.getInsets(WindowInsets.Type.navigationBars())
1730
+ navBarHeight = insets.bottom
1731
+ } else {
1732
+ val decorView = mActivity!!.window.decorView
1733
+ @Suppress("DEPRECATION")
1734
+ val isNavBarVisible = (decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0
1735
+ if (isNavBarVisible) {
1736
+ navBarHeight = getNavigationBarHeight(mActivity!!)
1737
+ }
1738
+ }
1739
+
1740
+ if (navBarHeight > 0) {
1741
+ bannerViewLayout?.let { container ->
1742
+ container.post {
1743
+ val params = container.layoutParams
1744
+ if (params is ViewGroup.MarginLayoutParams) {
1745
+ params.bottomMargin = navBarHeight
1746
+ container.layoutParams = params
1747
+ container.requestLayout()
1748
+ }
1749
+ }
1750
+ }
1751
+ }
1752
+ }
1753
+
1754
+
1755
+
1756
+ if (!isOverlapping) {
1757
+ val layoutParams = cWebView!!.view.layoutParams
1758
+
1759
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
1760
+ val windowMetrics = mActivity!!.windowManager.currentWindowMetrics
1761
+ val insets = windowMetrics.windowInsets.getInsets(WindowInsets.Type.systemBars())
1762
+ val usableHeight = windowMetrics.bounds.height()
1763
+
1764
+ layoutParams.height = if (isFullScreen) {
1765
+ // In fullscreen, do NOT subtract nav bar height
1766
+ usableHeight - adSize.getHeightInPixels(mActivity!!)
1767
+ } else {
1768
+ usableHeight - getNavigationBarHeight(mActivity!!) - adSize.getHeightInPixels(mActivity!!)
1769
+ }
1770
+ } else {
1771
+
1772
+ layoutParams.height = if (isFullScreen) {
1773
+ webViewHeight - adSize.getHeightInPixels(mActivity!!) + getNavigationBarHeight(mActivity!!)
1774
+ } else {
1775
+ webViewHeight - adSize.getHeightInPixels(mActivity!!) //- getNavigationBarHeight(mActivity!!)
1776
+ }
1777
+ }
1778
+
1779
+ cWebView!!.view.layoutParams = layoutParams
1780
+ }
1781
+
1782
+ val bannerParams = bannerView?.layoutParams as? FrameLayout.LayoutParams
1783
+ bannerParams?.bottomMargin = 0
1784
+ bannerParams?.gravity = Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL //81
1785
+ bannerView?.layoutParams = bannerParams
1786
+
1787
+ bannerViewLayout?.setPadding(0, 0, 0, 0)
1788
+
1789
+
1790
+ } catch (e: Exception) {
1791
+ PUBLIC_CALLBACKS?.error("Error bannerOverlapping: ${e.message}")
1792
+ }
1793
+ }
1794
+ }
1795
+ }
1796
+ }
1797
+
1798
+
1799
+
1800
+ private fun setBannerAdTopCapacitor() {
1801
+ mActivity?.let { activity ->
1802
+ bannerView?.post {
1803
+ val bannerHeightPx = bannerViewHeight
1804
+ val statusBarHeight = getStatusBarHeight(activity)
1805
+
1806
+ if (isPosition.equals("top-center", ignoreCase = true)) {
1807
+ val bannerLp = bannerView?.layoutParams as? FrameLayout.LayoutParams
1808
+ bannerLp?.let { lp ->
1809
+ if (isOverlapping) {
1810
+ if (isFullScreen) {
1811
+ lp.topMargin = 0
1812
+ bannerView?.layoutParams = lp
1813
+ } else {
1814
+ lp.topMargin = 0 // bannerHeightPx // + statusBarHeight
1815
+ bannerView?.layoutParams = lp
1816
+ }
1817
+ } else {
1818
+ if (isFullScreen) {
1819
+ lp.topMargin = 0
1820
+ bannerView?.layoutParams = lp
1821
+ } else {
1822
+ lp.topMargin = statusBarHeight
1823
+ bannerView?.layoutParams = lp
1824
+ }
1825
+ }
1826
+
1827
+ }
1828
+ }
1829
+
1830
+ cWebView?.let { webView ->
1831
+ val webLp = webView.view.layoutParams as FrameLayout.LayoutParams
1832
+ if (isPosition.equals("top-center", ignoreCase = true)) {
1833
+
1834
+ if (isOverlapping) {
1835
+ if (isFullScreen) {
1836
+ webLp.topMargin = 0 //+ statusBarHeight
1837
+ } else {
1838
+ webLp.topMargin = 0 //bannerHeightPx // + statusBarHeight
1839
+ }
1840
+ } else {
1841
+ if (isFullScreen) {
1842
+ webLp.topMargin = bannerHeightPx
1843
+ } else {
1844
+ webLp.topMargin = bannerHeightPx
1845
+ }
1846
+ }
1847
+ }
1848
+
1849
+ webView.view.layoutParams = webLp
1850
+ webView.view.requestLayout()
1851
+ }
1852
+ }}
1853
+ }
1854
+
1855
+
1856
+
1857
+
1858
+
1644
1859
  private val bannerPaidAdListener = OnPaidEventListener { adValue ->
1645
1860
  val valueMicros = adValue.valueMicros.takeIf { it > 0 } ?: 0L
1646
1861
  val currencyCode = adValue.currencyCode.ifBlank { "UNKNOWN" }
@@ -16,10 +16,18 @@
16
16
  @property(nonatomic, readonly) BOOL canRequestAds;
17
17
  @property (nonatomic, assign) BOOL isUsingAdManagerRequest;
18
18
  @property (nonatomic, assign) CGFloat viewWidth;
19
+ @property(nonatomic, assign) BOOL isOverlapping;
20
+ @property(nonatomic, assign) BOOL isCollapsible;
19
21
  @property (nonatomic, strong) UIView *bannerViewLayout;
20
22
  @property (nonatomic, strong) UIView *bannerContainer;
21
23
  @property (nonatomic, strong) UIView *webViewContainer;
22
24
 
25
+ @property(nonatomic, assign) BOOL isAutoShowAppOpen;
26
+ @property(nonatomic, assign) BOOL isAutoShowBanner;
27
+ @property(nonatomic, assign) BOOL isAutoShowInterstitial;
28
+ @property(nonatomic, assign) BOOL isAutoShowRewardedAds;
29
+ @property(nonatomic, assign) BOOL isAutoShowRewardedInt;
30
+
23
31
  - (void)initialize:(CDVInvokedUrlCommand *)command;
24
32
  - (void)requestIDFA:(CDVInvokedUrlCommand *)command;
25
33
  - (void)showPrivacyOptionsForm:(CDVInvokedUrlCommand *)command;
@@ -7,6 +7,7 @@
7
7
  #import <Cordova/CDVViewController.h>
8
8
 
9
9
  @implementation emiAdmobPlugin
10
+
10
11
  @synthesize appOpenAd;
11
12
  @synthesize bannerView;
12
13
  @synthesize interstitial;
@@ -15,25 +16,20 @@
15
16
  @synthesize command;
16
17
  @synthesize responseInfo;
17
18
  @synthesize isPrivacyOptionsRequired;
19
+
18
20
  int attStatus = 0;
19
- // int fromStatus = 0; // Deprecated
21
+
20
22
  int Consent_Status = 0;
21
23
  int adFormat = 0;
22
24
  int adWidth = 320; // Default
23
25
 
24
- BOOL auto_Show = NO;
25
26
  // NSString *Npa = @"1"; // Deprecated
26
27
  NSString *setPosition = @"bottom-center"; // Default
27
28
  NSString *bannerSaveAdUnitId = @""; // autoResize dependency = true
28
29
 
29
-
30
-
31
- BOOL isCollapsible = NO;
32
30
  BOOL isAutoResize = NO;
33
31
 
34
-
35
32
  CGFloat paddingWebView = 0; // Default
36
- BOOL isSetOverlapping = NO; // Default
37
33
  CGFloat bannerHeightFinal = 50; // Default
38
34
 
39
35
  int isAdSkip = 0;
@@ -60,10 +56,10 @@ NSString *setKeyword = @"";
60
56
  - (void)setAdRequest {
61
57
  if (isUsingAdManagerRequest) {
62
58
  self.globalRequest = [GAMRequest request];
63
- NSLog(@"Using AdManager request");
59
+ // NSLog(@"Using AdManager request");
64
60
  } else {
65
61
  self.globalRequest = [GADRequest request];
66
- NSLog(@"Using AdMob request");
62
+ // NSLog(@"Using AdMob request");
67
63
  }
68
64
 
69
65
  if (isEnabledKeyword && setKeyword.length > 0) {
@@ -71,7 +67,7 @@ NSString *setKeyword = @"";
71
67
  for (NSString *keyword in keywords) {
72
68
  NSString *trimmedKeyword = [keyword stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
73
69
  if (trimmedKeyword.length > 0) {
74
- NSLog(@"Adding keyword: %@", trimmedKeyword);
70
+ // NSLog(@"Adding keyword: %@", trimmedKeyword);
75
71
  [self.globalRequest setKeywords:[self.globalRequest.keywords arrayByAddingObject:trimmedKeyword]];
76
72
  }
77
73
  }
@@ -81,17 +77,9 @@ NSString *setKeyword = @"";
81
77
 
82
78
 
83
79
 
80
+ - (void)isResponseInfo:(BOOL)value { isResponseInfo = value; }
81
+ - (void)isDebugGeography:(BOOL)value { isDebugGeography = value; }
84
82
 
85
-
86
-
87
-
88
-
89
- - (void)isResponseInfo:(BOOL)value {
90
- isResponseInfo = value;
91
- }
92
- - (void)isDebugGeography:(BOOL)value {
93
- isDebugGeography = value;
94
- }
95
83
  - (void)initialize:(CDVInvokedUrlCommand *)command {
96
84
 
97
85
  NSDictionary *options = [command.arguments objectAtIndex:0];
@@ -154,11 +142,11 @@ NSString *setKeyword = @"";
154
142
  [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
155
143
  }];
156
144
  }
157
-
158
145
 
159
146
  if (UMPConsentInformation.sharedInstance.canRequestAds) {
160
147
  [self startGoogleMobileAdsSDK];
161
148
  }
149
+
162
150
  }];
163
151
  } else if (status == UMPConsentStatusNotRequired || status == UMPConsentStatusObtained) {
164
152
  if (UMPConsentInformation.sharedInstance.canRequestAds) {
@@ -183,8 +171,6 @@ NSString *setKeyword = @"";
183
171
 
184
172
  if (@available(iOS 14, *)) {
185
173
  dispatch_async(dispatch_get_main_queue(), ^{
186
- // Added a 1-second pause before performing a tracking authorization request
187
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
188
174
 
189
175
  [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
190
176
  if (status == ATTrackingManagerAuthorizationStatusDenied) {
@@ -200,7 +186,6 @@ NSString *setKeyword = @"";
200
186
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:attStatus];
201
187
  [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
202
188
  }];
203
- });
204
189
  });
205
190
  } else {
206
191
  [self fireEvent:@"" event:@"on.getIDFA.error" withData:nil];
@@ -254,26 +239,15 @@ NSString *setKeyword = @"";
254
239
  result[@"TCString"] = TCString;
255
240
  result[@"additionalConsent"] = additionalConsent;
256
241
 
257
- // NSLog(@"Result dictionary: %@", result);consentStatus
258
-
259
242
  NSError *error;
260
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:result
261
- options:0
262
- error:&error];
243
+ NSData *jsonData = [NSJSONSerialization dataWithJSONObject:result options:0 error:&error];
263
244
 
264
245
  if (!jsonData) {
265
- NSLog(@"Error converting result to JSON: %@",
266
- error.localizedDescription);
246
+ NSLog(@"Error converting result to JSON: %@", error.localizedDescription);
267
247
  } else {
268
- NSString *jsonString =
269
- [[NSString alloc] initWithData:jsonData
270
- encoding:NSUTF8StringEncoding];
271
-
272
- // NSLog(@"JSON String: %@", jsonString);
273
-
248
+ NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
274
249
  [self fireEvent:@"" event:@"on.sdkInitialization" withData:jsonString];
275
250
  }
276
-
277
251
  [prefs synchronize];
278
252
  }];
279
253
  });
@@ -316,6 +290,8 @@ NSString *setKeyword = @"";
316
290
  });
317
291
  }
318
292
 
293
+
294
+
319
295
  - (void)showPrivacyOptionsForm:(CDVInvokedUrlCommand *)command {
320
296
  NSString *deviceId = [self __getAdMobDeviceId];
321
297
  UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
@@ -370,10 +346,6 @@ NSString *setKeyword = @"";
370
346
 
371
347
 
372
348
 
373
-
374
-
375
-
376
-
377
349
  - (BOOL)isPrivacyOptionsRequired {
378
350
  UMPPrivacyOptionsRequirementStatus status = UMPConsentInformation.sharedInstance.privacyOptionsRequirementStatus;
379
351
 
@@ -399,10 +371,8 @@ NSString *setKeyword = @"";
399
371
  }
400
372
 
401
373
  CDVPluginResult *pluginResult =
402
- [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
403
- messageAsInt:Consent_Status];
404
- [self.commandDelegate sendPluginResult:pluginResult
405
- callbackId:command.callbackId];
374
+ [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:Consent_Status];
375
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
406
376
  }];
407
377
  }
408
378
 
@@ -462,8 +432,7 @@ NSString *setKeyword = @"";
462
432
  setPublisherFirstPartyIDEnabled:pubIdEnabled];
463
433
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
464
434
  } @catch (NSException *exception) {
465
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
466
- messageAsString:exception.reason];
435
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:exception.reason];
467
436
  }
468
437
  [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
469
438
  }
@@ -531,14 +500,11 @@ NSString *setKeyword = @"";
531
500
  result[@"IABTCF_PurposeConsents"] = PurposeConsents;
532
501
  result[@"IABTCF_TCString"] = TCString;
533
502
 
534
- // NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
535
-
536
503
  [prefs synchronize];
537
504
  }
538
505
 
539
506
 
540
507
  - (void)orientationDidChange:(NSNotification *)notification {
541
- // NSLog(@"Orientation changed");
542
508
  [self fireEvent:@"" event:@"on.screen.rotated" withData:nil];
543
509
  if (isAutoResize) {
544
510
  dispatch_async(dispatch_get_main_queue(), ^{
@@ -584,19 +550,16 @@ NSString *setKeyword = @"";
584
550
 
585
551
  [self.bannerViewLayout addSubview:self.bannerView];
586
552
  [self.bannerViewLayout bringSubviewToFront:self.bannerView];
587
-
588
- if (isSetOverlapping) {
589
-
590
- if (auto_Show && self.bannerView) {
591
- if (isSetOverlapping){
553
+
554
+ if (self.isAutoShowBanner && self.bannerView) {
555
+ if (!self.isOverlapping){
592
556
  self.bannerView.hidden = NO;
593
557
  [self setBodyHeight:self.command];
594
- }
558
+ } else {
559
+ self.bannerView.hidden = NO;
560
+ }
595
561
  }
596
562
 
597
-
598
- }
599
-
600
563
  } @catch (NSException *exception) {
601
564
  NSLog(@"Exception: %@", exception.reason);
602
565
  }
@@ -615,12 +578,11 @@ NSString *setKeyword = @"";
615
578
  NSString *collapsible = [options valueForKey:@"collapsible"];
616
579
  BOOL autoResize = [[options valueForKey:@"autoResize"] boolValue];
617
580
  NSString *size = [options valueForKey:@"size"];
618
- BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
581
+ self.isAutoShowBanner = [[options valueForKey:@"autoShow"] boolValue];
582
+ self.isOverlapping = [[options valueForKey:@"isOverlapping"] boolValue];
619
583
 
620
584
  bannerSaveAdUnitId = adUnitId;
621
-
622
585
  setPosition = position;
623
-
624
586
  adFormat = 5;
625
587
 
626
588
  if (adUnitId == nil || [adUnitId length] == 0) {
@@ -630,10 +592,10 @@ NSString *setKeyword = @"";
630
592
  return;
631
593
  }
632
594
 
633
- if (collapsible != nil && [collapsible length] > 0) {
634
- isCollapsible = YES;
595
+ if (collapsible != nil && [collapsible length] > 0) {
596
+ self.isCollapsible = YES;
635
597
  } else {
636
- isCollapsible = NO;
598
+ self.isCollapsible = NO;
637
599
  }
638
600
 
639
601
  if (autoResize) {
@@ -653,19 +615,16 @@ NSString *setKeyword = @"";
653
615
  }
654
616
 
655
617
  self.viewWidth = frame.size.width;
656
-
657
- auto_Show = autoShow;
618
+
658
619
  adWidth = self.viewWidth;
659
620
 
660
621
  GADAdSize siz = [self __AdSizeFromString:size];
661
622
  self.bannerView = [[GADBannerView alloc] initWithAdSize:siz];
662
623
 
663
-
664
624
  CGSize bannerSize = self.bannerView.bounds.size;
665
625
  CGFloat screenWidth = parentView.bounds.size.width;
666
626
  CGFloat screenHeight = parentView.bounds.size.height;
667
627
 
668
- // Default to top-center
669
628
  CGFloat originX = (screenWidth - bannerSize.width) / 2;
670
629
  CGFloat originY = 0;
671
630
 
@@ -680,9 +639,9 @@ NSString *setKeyword = @"";
680
639
 
681
640
  GADExtras *extras = [[GADExtras alloc] init];
682
641
 
683
- if (isCollapsible) {
642
+ if (self.isCollapsible) {
684
643
  extras.additionalParameters = @{@"collapsible" : collapsible};
685
-
644
+
686
645
  [self.globalRequest registerAdNetworkExtras:extras];
687
646
 
688
647
  }
@@ -700,7 +659,7 @@ NSString *setKeyword = @"";
700
659
 
701
660
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
702
661
  } else {
703
- // NSLog(@"Admob Option invalid for banner");
662
+
704
663
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
705
664
  }
706
665
 
@@ -711,11 +670,14 @@ NSString *setKeyword = @"";
711
670
  - (void)showBannerAd:(CDVInvokedUrlCommand *)command {
712
671
  @try {
713
672
  if (self.bannerView) {
714
- self.bannerView.hidden = NO;
715
- if (isSetOverlapping){
673
+
674
+ if (!self.isOverlapping){
675
+ self.bannerView.hidden = NO;
716
676
  [self setBodyHeight:command];
677
+ } else {
678
+ self.bannerView.hidden = NO;
717
679
  }
718
-
680
+
719
681
  } else {
720
682
  [self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
721
683
  }
@@ -828,7 +790,7 @@ NSString *setKeyword = @"";
828
790
  rootViewController.view.frame = contentFrame;
829
791
 
830
792
  }
831
-
793
+
832
794
  [self.bannerView setNeedsLayout];
833
795
  [self.bannerView layoutIfNeeded];
834
796
  [rootViewController.view setNeedsLayout];
@@ -860,10 +822,9 @@ NSString *setKeyword = @"";
860
822
 
861
823
  - (void)styleBannerAd:(CDVInvokedUrlCommand *)command {
862
824
  NSDictionary *options = [command.arguments objectAtIndex:0];
863
- BOOL isOverlapping = [[options valueForKey:@"isOverlapping"] boolValue];
825
+ self.isOverlapping = [[options valueForKey:@"isOverlapping"] boolValue];
864
826
  CGFloat paddingContainer = [[options valueForKey:@"paddingWebView"] floatValue];
865
827
 
866
- isSetOverlapping = isOverlapping;
867
828
  paddingWebView = paddingContainer;
868
829
 
869
830
  dispatch_async(dispatch_get_main_queue(), ^{
@@ -1022,15 +983,16 @@ NSString *setKeyword = @"";
1022
983
  }
1023
984
  [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
1024
985
  }
986
+
987
+
1025
988
  - (void)loadAppOpenAd:(CDVInvokedUrlCommand *)command {
1026
989
  CDVPluginResult *pluginResult;
1027
990
  NSString *callbackId = command.callbackId;
1028
991
 
1029
992
  NSDictionary *options = [command.arguments objectAtIndex:0];
1030
993
  NSString *adUnitId = [options valueForKey:@"adUnitId"];
1031
- BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
994
+ self.isAutoShowAppOpen = [[options valueForKey:@"autoShow"] boolValue];
1032
995
 
1033
- auto_Show = autoShow;
1034
996
  adFormat = 1;
1035
997
  self.appOpenAd = nil;
1036
998
 
@@ -1084,7 +1046,7 @@ NSString *setKeyword = @"";
1084
1046
  };
1085
1047
 
1086
1048
 
1087
- if (auto_Show) {
1049
+ if (self.isAutoShowAppOpen) {
1088
1050
  NSError *presentError = nil;
1089
1051
  if ([self.appOpenAd canPresentFromRootViewController:self.viewController error:&presentError]) {
1090
1052
  [self.appOpenAd presentFromRootViewController:self.viewController];
@@ -1146,9 +1108,7 @@ NSString *setKeyword = @"";
1146
1108
  - (void)showAppOpenAd:(CDVInvokedUrlCommand *)command {
1147
1109
  CDVPluginResult *pluginResult;
1148
1110
  NSString *callbackId = command.callbackId;
1149
- if (self.appOpenAd &&
1150
- [self.appOpenAd canPresentFromRootViewController:self.viewController
1151
- error:nil]) {
1111
+ if (self.appOpenAd && [self.appOpenAd canPresentFromRootViewController:self.viewController error:nil]) {
1152
1112
  [self.appOpenAd presentFromRootViewController:self.viewController];
1153
1113
  adFormat = 1;
1154
1114
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
@@ -1158,15 +1118,16 @@ NSString *setKeyword = @"";
1158
1118
  }
1159
1119
  [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
1160
1120
  }
1121
+
1122
+
1161
1123
  - (void)loadInterstitialAd:(CDVInvokedUrlCommand *)command {
1162
1124
  CDVPluginResult *pluginResult;
1163
1125
  NSString *callbackId = command.callbackId;
1164
1126
 
1165
1127
  NSDictionary *options = [command.arguments objectAtIndex:0];
1166
1128
  NSString *adUnitId = [options valueForKey:@"adUnitId"];
1167
- BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
1129
+ self.isAutoShowInterstitial = [[options valueForKey:@"autoShow"] boolValue];
1168
1130
 
1169
- auto_Show = autoShow;
1170
1131
  adFormat = 2;
1171
1132
  [self setAdRequest];
1172
1133
  if (adFormat == 2) {
@@ -1213,7 +1174,7 @@ NSString *setKeyword = @"";
1213
1174
  };
1214
1175
 
1215
1176
 
1216
- if (auto_Show) {
1177
+ if (self.isAutoShowInterstitial) {
1217
1178
  NSError *presentError = nil;
1218
1179
  if ([self.interstitial canPresentFromRootViewController:self.viewController error:&presentError]) {
1219
1180
  [self.interstitial presentFromRootViewController:self.viewController];
@@ -1300,9 +1261,8 @@ NSString *setKeyword = @"";
1300
1261
 
1301
1262
  NSDictionary *options = [command.arguments objectAtIndex:0];
1302
1263
  NSString *adUnitId = [options valueForKey:@"adUnitId"];
1303
- BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
1264
+ self.isAutoShowRewardedInt = [[options valueForKey:@"autoShow"] boolValue];
1304
1265
 
1305
- auto_Show = autoShow;
1306
1266
  adFormat = 4;
1307
1267
  [self setAdRequest];
1308
1268
  if (adFormat == 4) {
@@ -1348,7 +1308,7 @@ NSString *setKeyword = @"";
1348
1308
  };
1349
1309
 
1350
1310
 
1351
- if (auto_Show) {
1311
+ if (self.isAutoShowRewardedInt) {
1352
1312
  NSError *presentError = nil;
1353
1313
  if ([self.rewardedInterstitialAd canPresentFromRootViewController:self.viewController error:&presentError]) {
1354
1314
  [self.rewardedInterstitialAd presentFromRootViewController:self.viewController userDidEarnRewardHandler:^{
@@ -1461,10 +1421,7 @@ NSString *setKeyword = @"";
1461
1421
  NSString *callbackId = command.callbackId;
1462
1422
  NSDictionary *options = [command.arguments objectAtIndex:0];
1463
1423
  NSString *adUnitId = [options valueForKey:@"adUnitId"];
1464
- BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
1465
- //auto_Show = autoShow;
1466
-
1467
- __block BOOL shouldAutoShow = autoShow;
1424
+ self.isAutoShowRewardedAds = [[options valueForKey:@"autoShow"] boolValue];
1468
1425
 
1469
1426
  adFormat = 3;
1470
1427
  [self setAdRequest];
@@ -1509,7 +1466,7 @@ NSString *setKeyword = @"";
1509
1466
 
1510
1467
 
1511
1468
 
1512
- if (shouldAutoShow) {
1469
+ if (self.isAutoShowRewardedAds) {
1513
1470
  NSError *presentError = nil;
1514
1471
  if ([self.rewardedAd canPresentFromRootViewController:self.viewController error:&presentError]) {
1515
1472
  [self.rewardedAd presentFromRootViewController:self.viewController userDidEarnRewardHandler:^{
@@ -1712,7 +1669,7 @@ NSString *setKeyword = @"";
1712
1669
  #pragma mark GADBannerViewDelegate implementation
1713
1670
 
1714
1671
  - (void)bannerViewDidReceiveAd:(GADBannerView *)bannerView {
1715
- // NSLog(@"The last loaded banner is %@collapsible.", (bannerView.isCollapsible ? @"" : @"not "));
1672
+
1716
1673
  NSString *collapsibleStatus = bannerView.isCollapsible ? @"collapsible" : @"not collapsible";
1717
1674
  NSDictionary *eventData = @{@"collapsible" : collapsibleStatus};
1718
1675
  NSError *error;
@@ -1723,29 +1680,24 @@ NSString *setKeyword = @"";
1723
1680
  [self fireEvent:@"" event:@"on.is.collapsible" withData:jsonString];
1724
1681
  }
1725
1682
 
1726
- // Get the banner height
1727
1683
  CGFloat bannerHeight = bannerView.bounds.size.height;
1728
1684
  bannerHeightFinal = bannerHeight;
1729
1685
 
1730
-
1731
- // Prepare height data for banner load event
1732
1686
  NSDictionary *bannerLoadData = @{@"height" : @(bannerHeight)};
1733
1687
  NSData *bannerLoadJsonData = [NSJSONSerialization dataWithJSONObject:bannerLoadData options:0 error:&error];
1734
1688
  NSString *bannerLoadJsonString = [[NSString alloc] initWithData:bannerLoadJsonData encoding:NSUTF8StringEncoding];
1735
1689
 
1736
- // Fire the banner load event with the height data
1737
1690
  [self fireEvent:@"" event:@"on.banner.load" withData:bannerLoadJsonString];
1738
1691
 
1739
- if (auto_Show && self.bannerView) {
1740
- if (isSetOverlapping){
1692
+ if (self.isAutoShowBanner && self.bannerView) {
1693
+ if (!self.isOverlapping){
1741
1694
  self.bannerView.hidden = NO;
1742
1695
  [self setBodyHeight:command];
1743
- }
1744
- } else {
1745
- [self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
1696
+ } else {
1697
+ self.bannerView.hidden = NO;
1698
+ }
1746
1699
  }
1747
1700
 
1748
-
1749
1701
  __weak __typeof(self) weakSelf = self;
1750
1702
  self.bannerView.paidEventHandler = ^(GADAdValue *_Nonnull value) {
1751
1703
  __strong __typeof(weakSelf) strongSelf = weakSelf;
@@ -16,16 +16,19 @@ exports.showAppOpenAd = function (success, error) {
16
16
  exec(success, error, 'emiAdmobPlugin', 'showAppOpenAd', []);
17
17
  };
18
18
  exports.styleBannerAd = function (options, success, error) {
19
- exec(success, error, 'emiAdmobPlugin', 'styleBannerAd', [options]);
19
+ exec(success, error, 'emiAdmobPlugin', 'styleBannerAd', [options]);
20
20
  };
21
21
  exports.loadBannerAd = function (options, success, error) {
22
22
  exec(success, error, 'emiAdmobPlugin', 'loadBannerAd', [options]);
23
23
  };
24
+ exports.loadBannerCapacitor = function (options, success, error) {
25
+ exec(success, error, 'emiAdmobPlugin', 'loadBannerCapacitor', [options]);
26
+ };
24
27
  exports.showBannerAd = function (success, error) {
25
28
  exec(success, error, 'emiAdmobPlugin', 'showBannerAd', []);
26
29
  };
27
30
  exports.hideBannerAd = function (success, error) {
28
- exec(success, error, 'emiAdmobPlugin', 'hideBannerAd', []);
31
+ exec(success, error, 'emiAdmobPlugin', 'hideBannerAd', []);
29
32
  };
30
33
  exports.removeBannerAd = function (success, error) {
31
34
  exec(success, error, 'emiAdmobPlugin', 'removeBannerAd', []);
@@ -70,13 +73,13 @@ exports.globalSettings = function (options, success, error) {
70
73
  exec(success, error, 'emiAdmobPlugin', 'globalSettings', [options]);
71
74
  };
72
75
  exports.forceDisplayPrivacyForm = function (success, error) {
73
- exec(success, error, 'emiAdmobPlugin', 'forceDisplayPrivacyForm', []); // only IOS
76
+ exec(success, error, 'emiAdmobPlugin', 'forceDisplayPrivacyForm', []);
74
77
  };
75
78
 
76
79
  exports.metaData = function (options, success, error) {
77
80
  exec(success, error, 'emiAdmobPlugin', 'metaData', [options]);
78
81
  };
79
-
82
+
80
83
  // ( only Android )
81
84
  // only isUsingAdManagerRequest: true
82
85
  // AdManagerAdRequest.Builder