emi-indo-cordova-plugin-admob 1.6.2 → 1.6.4

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
@@ -11,9 +11,9 @@
11
11
  ### Mobile Ads SDK (Android: 23.5.0) [Release Notes:](https://developers.google.com/admob/android/rel-notes)
12
12
  ### User Messaging Platform (UMP Android: 3.1.0) [Release Notes:](https://developers.google.com/admob/android/privacy/release-notes)
13
13
 
14
- ### Mobile Ads SDK (IOS: 11.10.0) [Release Notes:](https://developers.google.com/admob/ios/rel-notes)
14
+ ### Mobile Ads SDK (IOS: 11.12.0) [Release Notes:](https://developers.google.com/admob/ios/rel-notes)
15
15
 
16
- ### User Messaging Platform (UMP IOS: 2.6.0) [Release Notes:](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/privacy/download)
16
+ ### User Messaging Platform (UMP IOS: 2.7.0) [Release Notes:](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/privacy/download)
17
17
  ### IAB Europe Transparency & Consent Framework (CPM: 2.2.0)
18
18
 
19
19
  ## New example
@@ -31,7 +31,10 @@
31
31
 
32
32
 
33
33
  ## IOS Ad Support IOS 18 *
34
+ - Mobile Ads SDK (IOS: 11.12.0)
35
+ - emi-indo-cordova-plugin-admob@1.6.3 or higher requires cocoapods 1.16.2 or higher
34
36
  > [!WARNING]
37
+ > - Mobile Ads SDK (IOS: 11.10.0)
35
38
  > - emi-indo-cordova-plugin-admob@1.5.2 or higher
36
39
  > - Minimum supported Xcode version up to 15.3 or higher
37
40
  > - minimum deployment-target: 12.2
@@ -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": "^1.6.1"
17
+ "emi-indo-cordova-plugin-admob": "^1.6.4"
18
18
  },
19
19
  "cordova": {
20
20
  "plugins": {
@@ -6,6 +6,7 @@
6
6
  <script src="js/bannerAd.js" defer></script>
7
7
  <script src="js/interstitialAd.js" defer></script>
8
8
  <script src="js/rewardedAd.js" defer></script>
9
+ <script src="js/rewardedInterstitialAd.js" defer></script>
9
10
  </head>
10
11
  <body>
11
12
 
@@ -22,6 +23,9 @@
22
23
  <p> <button onclick="loadRewarded();">Load Rewarded Ad</button></p>
23
24
  <p> <button onclick="showRewarded();">Show Rewarded Ad</button></p>
24
25
 
26
+ <p> <button onclick="loadRewardedInt();">Load Rewarded Int Ad</button></p>
27
+ <p> <button onclick="showRewardedInt();">Show Rewarded int Ad</button></p>
28
+
25
29
  <p> <button onclick="cleanText();">Clean response Text</button></p>
26
30
 
27
31
  </body>
@@ -87,7 +87,7 @@ document.addEventListener("deviceready", function () {
87
87
 
88
88
  cordova.plugins.emiAdmobPlugin.initialize({
89
89
 
90
- isUsingAdManagerRequest: true, // AdManagerAdRequest.Builder | AdRequest.Builder (Default true)
90
+ isUsingAdManagerRequest: true, // true = AdManager | false = AdMob (Default true)
91
91
  isResponseInfo: true, // debug Default false
92
92
  isConsentDebug: true, // debug Default false
93
93
 
@@ -101,6 +101,7 @@ document.addEventListener("deviceready", function () {
101
101
  const sdkVersion = data.version;
102
102
  // const adAdapter = data.adapters;
103
103
  const conStatus = data.consentStatus;
104
+ const attStatus = data.attStatus;
104
105
  // const gdprApplie = data.gdprApplies;
105
106
  // const purposeConsent = data.purposeConsents;
106
107
  // const vendorConsents = data.vendorConsents;
@@ -108,6 +109,11 @@ document.addEventListener("deviceready", function () {
108
109
  // const additionalConsent = data.additionalConsent;
109
110
  log.value += ("\n On Sdk Initialization version: " + sdkVersion);
110
111
  log.value += ("\n On Consent Status: " + conStatus);
112
+
113
+ if (isPlatformIOS){
114
+
115
+ log.value += ("\n On Authorization Status: " + attStatus);
116
+ }
111
117
 
112
118
  loadBanner(); // auto show
113
119
 
@@ -0,0 +1,124 @@
1
+
2
+
3
+ let isRewardedIntLoad = false;
4
+
5
+ function loadRewardedInt() {
6
+
7
+ if (typeof cordova !== 'undefined') {
8
+ cordova.plugins.emiAdmobPlugin.loadRewardedInterstitialAd({ adUnitId: Rewarded_Interstitial_ID, autoShow: false });
9
+ }
10
+
11
+ }
12
+
13
+ function showRewardedInt() {
14
+
15
+ if (typeof cordova !== 'undefined') {
16
+ if (isRewardedIntLoad) {
17
+ cordova.plugins.emiAdmobPlugin.showRewardedInterstitialAd();
18
+ }
19
+ }
20
+
21
+ }
22
+
23
+
24
+ /*
25
+ on.rewardedInt.loaded
26
+ on.rewardedInt.failed.load
27
+ on.rewardedInt.click
28
+ on.rewardedInt.dismissed
29
+ on.rewardedInt.failed.show
30
+ on.rewardedInt.impression
31
+ on.rewardedInt.showed
32
+ on.rewardedInt.userEarnedReward
33
+ // new
34
+ on.rewardedInt.revenue
35
+ on.rewardedInt.ad.skip
36
+ on.rewardedIntAd.responseInfo
37
+
38
+ */
39
+
40
+
41
+
42
+ document.addEventListener('on.rewardedInt.loaded', () => {
43
+ isRewardedIntLoad = true;
44
+ console.log("on.rewardedInt.loaded");
45
+ window.log.value += ("\n on.rewardedInt.loaded");
46
+ });
47
+
48
+
49
+ document.addEventListener('on.rewardedInt.failed.load', (error) => {
50
+ isRewardedIntLoad = false;
51
+ console.log("on.rewardedInt.failed.load" + JSON.stringify(error));
52
+
53
+ window.log.value += ("\n on.rewardedInt.failed.load" + JSON.stringify(error));
54
+ });
55
+
56
+
57
+ document.addEventListener('on.rewardedInt.failed.show', (error) => {
58
+ isRewardedIntLoad = false;
59
+ console.log("on.rewardedInt.failed.show" + JSON.stringify(error));
60
+
61
+ window.log.value += ("\n on.rewardedInt.failed.show" + JSON.stringify(error));
62
+ });
63
+
64
+
65
+ document.addEventListener('on.rewardedInt.userEarnedReward', (rewarded) => {
66
+ // Give gifts to users here
67
+ isRewardedIntLoad = false;
68
+ console.log("Give gifts to users here" + JSON.stringify(rewarded));
69
+ // const rewardAmount = rewarded.amount;
70
+ // const rewardType = rewarded.currency;
71
+ window.log.value += ("\n Give gifts to users here" + JSON.stringify(rewarded));
72
+ });
73
+
74
+
75
+ // all events that contain the keyword dismissed there is a block to load the ad after it is closed by the user.
76
+ document.addEventListener('on.rewardedInt.dismissed', () => {
77
+ isRewardedIntLoad = false;
78
+ console.log("on.rewardedInt.dismissed");
79
+ console.log("you can load ads automatically after the ads are closed by users");
80
+ loadRewardedInt();
81
+
82
+ window.log.value += ("\n you can load ads automatically after the ads are closed by users");
83
+
84
+ });
85
+
86
+
87
+
88
+
89
+
90
+ /*
91
+ // DEBUG
92
+ // isResponseInfo: true, // debug Default false
93
+ document.addEventListener('on.rewardedIntAd.responseInfo', (data) => {
94
+
95
+ console.log("on.rewardedIntAd.responseInfo" + JSON.stringify(data));
96
+ if (window.log) window.log.value += ("\n on.rewardedIntAd.responseInfo" + JSON.stringify(data));
97
+ });
98
+
99
+ */
100
+
101
+
102
+
103
+
104
+
105
+ /*
106
+ https://support.google.com/admob/answer/11322405
107
+
108
+ Turn on the setting for impression-level ad revenue in your AdMob account:
109
+ Sign in to your AdMob account at https://apps.admob.com.
110
+ Click Settings in the sidebar.
111
+ Click the Account tab.
112
+ In the Account controls section, click the Impression-level ad revenue toggle to turn on this setting.
113
+ */
114
+
115
+ document.addEventListener('on.rewardedInt.revenue', (data) => {
116
+
117
+ console.log(data.value)
118
+ console.log(data.currencyCode)
119
+ console.log(data.precision)
120
+ console.log(data.adUnitId)
121
+
122
+ // console.log("on.rewardedInt.revenue" + JSON.stringify(data));
123
+ if (window.log) window.log.value += ("\n on.rewardedInt.revenue" + JSON.stringify(data));
124
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emi-indo-cordova-plugin-admob",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "description": "Cordova Plugin Admob Android IOS Support Capacitor",
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.6.2">
3
+ id="emi-indo-cordova-plugin-admob" version="1.6.4">
4
4
 
5
5
  <name>emiAdmobPlugin</name>
6
6
  <description>Cordova Plugin Admob Android IOS</description>
@@ -296,8 +296,8 @@
296
296
  </config>
297
297
  <pods use-frameworks="true">
298
298
  <!--minimum macOS 14.4 > Xcode 15.3 -->
299
- <pod name="GoogleUserMessagingPlatform" spec="~> 2.6.0" />
300
- <pod name="Google-Mobile-Ads-SDK" spec="~> 11.10.0" />
299
+ <pod name="GoogleUserMessagingPlatform" spec="~> 2.7.0" />
300
+ <pod name="Google-Mobile-Ads-SDK" spec="~> 11.12.0" />
301
301
 
302
302
  </pods>
303
303
  </podspec>
@@ -462,7 +462,6 @@ class emiAdmobPlugin : CordovaPlugin() {
462
462
  }
463
463
 
464
464
 
465
-
466
465
  }
467
466
 
468
467
  private fun openAutoShow() {
@@ -478,22 +477,22 @@ class emiAdmobPlugin : CordovaPlugin() {
478
477
  PUBLIC_CALLBACKS!!.error(e.toString())
479
478
  }
480
479
  }
481
-
482
480
  override fun onAdFailedToLoad(loadAdError: LoadAdError) {
483
481
  isAppOpenAdShow = false
484
482
  val errorData = JSONObject().apply {
485
- put("responseInfo", loadAdError.responseInfo)
483
+ put("responseInfo", loadAdError.responseInfo.toString())
486
484
  put("code", loadAdError.code)
487
485
  put("message", loadAdError.message)
488
486
  put("domain", loadAdError.domain)
489
487
  put("cause", loadAdError.cause?.toString() ?: "null")
490
488
  }
491
- cWebView!!.loadUrl(
492
- "javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.loaded, ${errorData}');"
489
+ cWebView?.loadUrl(
490
+ "javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.loaded', ${errorData});"
493
491
  )
494
492
  }
493
+
495
494
  })
496
- } catch (e: Exception) {
495
+ } catch (e: Exception) {
497
496
  callbackContext.error(e.toString())
498
497
  }
499
498
  }
@@ -595,7 +594,7 @@ class emiAdmobPlugin : CordovaPlugin() {
595
594
  mInterstitialAd = null
596
595
  isInterstitialLoad = false
597
596
  val errorData = JSONObject().apply {
598
- put("responseInfo", loadAdError.responseInfo)
597
+ put("responseInfo", loadAdError.responseInfo.toString())
599
598
  put("code", loadAdError.code)
600
599
  put("message", loadAdError.message)
601
600
  put("domain", loadAdError.domain)
@@ -638,7 +637,7 @@ class emiAdmobPlugin : CordovaPlugin() {
638
637
  isRewardedLoad = false
639
638
 
640
639
  val errorData = JSONObject().apply {
641
- put("responseInfo", loadAdError.responseInfo)
640
+ put("responseInfo", loadAdError.responseInfo.toString())
642
641
  put("code", loadAdError.code)
643
642
  put("message", loadAdError.message)
644
643
  put("domain", loadAdError.domain)
@@ -888,7 +887,7 @@ class emiAdmobPlugin : CordovaPlugin() {
888
887
  rewardedInterstitialAd = null
889
888
  isRewardedInterstitialLoad = false
890
889
  val errorData = JSONObject().apply {
891
- put("responseInfo", loadAdError.responseInfo)
890
+ put("responseInfo", loadAdError.responseInfo.toString())
892
891
  put("code", loadAdError.code)
893
892
  put("message", loadAdError.message)
894
893
  put("domain", loadAdError.domain)
@@ -1164,35 +1163,6 @@ class emiAdmobPlugin : CordovaPlugin() {
1164
1163
  }
1165
1164
 
1166
1165
 
1167
- private fun handleConsentForm() {
1168
- if(mActivity != null) {
1169
- if (consentInformation!!.isConsentFormAvailable) {
1170
- mContext?.let {
1171
- UserMessagingPlatform.loadConsentForm(it,
1172
- { consentForm: ConsentForm ->
1173
- mActivity?.let { it1 ->
1174
- consentForm.show(
1175
- it1
1176
- ) { formError: FormError? ->
1177
- if (formError != null) {
1178
- mActivity!!.runOnUiThread {
1179
- cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.show', { message: '" + formError.message + "' });")
1180
- }
1181
- }
1182
- }
1183
- }
1184
- },
1185
- { formError: FormError ->
1186
- cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.load.from', { message: '" + formError.message + "' });")
1187
- }
1188
- )
1189
- }
1190
- }
1191
- }
1192
- }
1193
-
1194
-
1195
-
1196
1166
 
1197
1167
  private fun loadBannerAd(adUnitId: String, position: String, size: String) {
1198
1168
  try {
@@ -1210,7 +1180,6 @@ class emiAdmobPlugin : CordovaPlugin() {
1210
1180
  bannerView!!.adUnitId = adUnitId
1211
1181
  bannerView!!.adListener = bannerAdListener
1212
1182
  bannerView!!.loadAd(buildAdRequest())
1213
- // adjustWebViewForBanner(position)
1214
1183
  } else {
1215
1184
  Log.d(TAG, "Banner view layout already exists.")
1216
1185
  }
@@ -1220,28 +1189,6 @@ class emiAdmobPlugin : CordovaPlugin() {
1220
1189
  }
1221
1190
  }
1222
1191
 
1223
- private fun adjustWebViewForBanner(position: String?) {
1224
- val rootView = bannerViewLayout
1225
- val webView = rootView?.findViewById<View>(View.generateViewId())
1226
-
1227
- if (webView != null) {
1228
- when (position) {
1229
- "bottom-center", "bottom-right" -> {
1230
- webView.setPadding(0, 0, 0, bannerView!!.height)
1231
- }
1232
- "top-center", "top-right" -> {
1233
- webView.setPadding(0, bannerView!!.height, 0, 0)
1234
- }
1235
- else -> {
1236
- webView.setPadding(0, 0, 0, 0)
1237
- }
1238
- }
1239
- webView.requestLayout()
1240
- }
1241
- }
1242
-
1243
-
1244
-
1245
1192
 
1246
1193
 
1247
1194
 
@@ -1355,16 +1302,18 @@ class emiAdmobPlugin : CordovaPlugin() {
1355
1302
  cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.close');")
1356
1303
  }
1357
1304
 
1358
- override fun onAdFailedToLoad(adError: LoadAdError) {
1359
1305
 
1306
+ override fun onAdFailedToLoad(adError: LoadAdError) {
1360
1307
  val errorData = JSONObject().apply {
1361
- put("responseInfo", adError.responseInfo)
1308
+ put("responseInfo", adError.responseInfo.toString())
1362
1309
  put("code", adError.code)
1363
1310
  put("message", adError.message)
1364
1311
  put("domain", adError.domain)
1365
1312
  put("cause", adError.cause?.toString() ?: "null")
1366
1313
  }
1367
1314
 
1315
+ cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.failed.load', ${errorData});")
1316
+
1368
1317
  bannerOverlappingToZero()
1369
1318
 
1370
1319
  if (bannerViewLayout != null && bannerView != null) {
@@ -1379,7 +1328,7 @@ class emiAdmobPlugin : CordovaPlugin() {
1379
1328
  }
1380
1329
 
1381
1330
 
1382
- cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.failed.load', ${errorData});")
1331
+
1383
1332
  }
1384
1333
 
1385
1334
  override fun onAdImpression() {
@@ -1608,6 +1557,33 @@ class emiAdmobPlugin : CordovaPlugin() {
1608
1557
 
1609
1558
 
1610
1559
 
1560
+ private fun handleConsentForm() {
1561
+ if(mActivity != null) {
1562
+ if (consentInformation!!.isConsentFormAvailable) {
1563
+ mContext?.let {
1564
+ UserMessagingPlatform.loadConsentForm(it,
1565
+ { consentForm: ConsentForm ->
1566
+ mActivity?.let { it1 ->
1567
+ consentForm.show(
1568
+ it1
1569
+ ) { formError: FormError? ->
1570
+ if (formError != null) {
1571
+ mActivity!!.runOnUiThread {
1572
+ cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.show', { message: '" + formError.message + "' });")
1573
+ }
1574
+ }
1575
+ }
1576
+ }
1577
+ },
1578
+ { formError: FormError ->
1579
+ cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.load.from', { message: '" + formError.message + "' });")
1580
+ }
1581
+ )
1582
+ }
1583
+ }
1584
+ }
1585
+ }
1586
+
1611
1587
 
1612
1588
  private fun setUsingAdManagerRequest(isUsingAdManagerRequest: Boolean) {
1613
1589
  this.isUsingAdManagerRequest = isUsingAdManagerRequest
@@ -2080,9 +2056,7 @@ class emiAdmobPlugin : CordovaPlugin() {
2080
2056
  if (View::class.java.isAssignableFrom(CordovaWebView::class.java)) {
2081
2057
  return cWebView as View?
2082
2058
  }
2083
-
2084
2059
  return mActivity!!.window.decorView.findViewById(View.generateViewId())
2085
- // return mActivity!!.window.decorView.findViewById(R.id.content)
2086
2060
  }
2087
2061
 
2088
2062
  override fun onPause(multitasking: Boolean) {
@@ -2126,4 +2100,6 @@ class emiAdmobPlugin : CordovaPlugin() {
2126
2100
  private const val LAST_ACCESS_SUFFIX = "_last_access"
2127
2101
  private const val EXPIRATION_TIME = 360L * 24 * 60 * 60 * 1000
2128
2102
  }
2129
- }
2103
+ }
2104
+
2105
+
@@ -4,6 +4,7 @@
4
4
  #import <UserMessagingPlatform/UserMessagingPlatform.h>
5
5
  #import <CommonCrypto/CommonDigest.h>
6
6
  @interface emiAdmobPlugin : CDVPlugin<GADBannerViewDelegate, GADFullScreenContentDelegate>{}
7
+ @property(nonatomic, strong) GADRequest *globalRequest;
7
8
  @property(nonatomic, strong) GADAppOpenAd *appOpenAd;
8
9
  @property(nonatomic, strong) GADBannerView *bannerView;
9
10
  @property(nonatomic, strong) GADInterstitialAd *interstitial;
@@ -20,7 +21,6 @@
20
21
  - (void)initialize:(CDVInvokedUrlCommand *)command;
21
22
  - (void)requestIDFA:(CDVInvokedUrlCommand *)command;
22
23
  - (void)showPrivacyOptionsForm:(CDVInvokedUrlCommand *)command;
23
- // - (void)getConsentRequest:(CDVInvokedUrlCommand *)command;
24
24
  - (void)forceDisplayPrivacyForm:(CDVInvokedUrlCommand *)command;
25
25
  - (void)consentReset:(CDVInvokedUrlCommand *)command;
26
26
  - (void)getIabTfc:(CDVInvokedUrlCommand *)command;
@@ -13,25 +13,24 @@
13
13
  @synthesize command;
14
14
  @synthesize responseInfo;
15
15
  @synthesize isPrivacyOptionsRequired;
16
- int idfaStatus = 0;
16
+ int attStatus = 0;
17
17
  // int fromStatus = 0; // Deprecated
18
18
  int Consent_Status = 0;
19
19
  int adFormat = 0;
20
- int adWidth = 320; // Deprecated
20
+ int adWidth = 320; // Default
21
21
  BOOL auto_Show = NO;
22
22
  // NSString *Npa = @"1"; // Deprecated
23
- NSString *Position = @"bottom-center"; // Default
23
+ NSString *setPosition = @"bottom-center"; // Default
24
24
  NSString *bannerSaveAdUnitId = @""; // autoResize dependency = true
25
25
 
26
- BOOL enableCollapsible = NO;
26
+ BOOL isCollapsible = NO;
27
27
  BOOL isAutoResize = NO;
28
28
 
29
29
  int isAdSkip = 0;
30
- BOOL isIAB = NO;
31
30
  BOOL UnderAgeOfConsent = NO;
32
31
  BOOL isPrivacyOptions = NO;
33
32
  BOOL isDebugGeography = NO;
34
- BOOL ResponseInfo = NO;
33
+ BOOL isResponseInfo = NO;
35
34
  BOOL isUsingAdManagerRequest = YES;
36
35
 
37
36
  - (BOOL)canRequestAds {
@@ -40,8 +39,20 @@ BOOL isUsingAdManagerRequest = YES;
40
39
  - (void)setUsingAdManagerRequest:(BOOL)value {
41
40
  isUsingAdManagerRequest = value;
42
41
  }
43
- - (void)ResponseInfo:(BOOL)value {
44
- ResponseInfo = value;
42
+
43
+ - (void)setAdRequest {
44
+ if (isUsingAdManagerRequest) {
45
+ self.globalRequest = [GAMRequest request];
46
+ NSLog(@"Using AdManager request");
47
+ } else {
48
+ self.globalRequest = [GADRequest request];
49
+ NSLog(@"Using AdMob request");
50
+ }
51
+ }
52
+
53
+
54
+ - (void)isResponseInfo:(BOOL)value {
55
+ isResponseInfo = value;
45
56
  }
46
57
  - (void)isDebugGeography:(BOOL)value {
47
58
  isDebugGeography = value;
@@ -55,7 +66,7 @@ BOOL isUsingAdManagerRequest = YES;
55
66
  BOOL setDebugGeography = [[options valueForKey:@"isConsentDebug"] boolValue];
56
67
 
57
68
  [self setUsingAdManagerRequest:setAdRequest];
58
- [self ResponseInfo:responseInfo];
69
+ [self isResponseInfo:responseInfo];
59
70
  [self isDebugGeography:setDebugGeography];
60
71
 
61
72
  __block CDVPluginResult *pluginResult;
@@ -132,42 +143,28 @@ BOOL isUsingAdManagerRequest = YES;
132
143
  [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(
133
144
  ATTrackingManagerAuthorizationStatus status) {
134
145
  if (status == ATTrackingManagerAuthorizationStatusDenied) {
135
- idfaStatus = ATTrackingManagerAuthorizationStatusDenied;
146
+ attStatus = ATTrackingManagerAuthorizationStatusDenied;
136
147
  } else if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
137
- idfaStatus = ATTrackingManagerAuthorizationStatusAuthorized;
148
+ attStatus = ATTrackingManagerAuthorizationStatusAuthorized;
138
149
  } else if (status == ATTrackingManagerAuthorizationStatusRestricted) {
139
- idfaStatus = ATTrackingManagerAuthorizationStatusRestricted;
150
+ attStatus = ATTrackingManagerAuthorizationStatusRestricted;
140
151
  } else if (status ==
141
152
  ATTrackingManagerAuthorizationStatusNotDetermined) {
142
- idfaStatus = ATTrackingManagerAuthorizationStatusNotDetermined;
153
+ attStatus = ATTrackingManagerAuthorizationStatusNotDetermined;
143
154
  }
144
155
  }];
145
156
  });
146
- [self fireEvent:@""
147
- event:@"on."
148
- @"getI"
149
- @"DFA."
150
- @"stat"
151
- @"us"
152
- withData:nil];
157
+ [self fireEvent:@"" event:@"on.getIDFA.status" withData:nil];
158
+
153
159
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
154
- messageAsInt:idfaStatus];
160
+ messageAsInt:attStatus];
155
161
  } else {
156
- [self fireEvent:@""
157
- event:@"on."
158
- @"getI"
159
- @"DFA."
160
- @"erro"
161
- @"r"
162
- withData:nil];
162
+ [self fireEvent:@"" event:@"on.getIDFA.error" withData:nil];
163
163
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
164
164
  }
165
165
  [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
166
166
  }
167
- /*
168
- - (void)getConsentRequest:(CDVInvokedUrlCommand *)command {
169
- }
170
- */
167
+
171
168
  - (void)startGoogleMobileAdsSDK {
172
169
  static dispatch_once_t onceToken;
173
170
  dispatch_once(&onceToken, ^{
@@ -187,22 +184,21 @@ BOOL isUsingAdManagerRequest = YES;
187
184
  [adaptersArray addObject:adapterInfo];
188
185
  }
189
186
 
190
- NSString *sdkVersion = GADGetStringFromVersionNumber(
191
- GADMobileAds.sharedInstance.versionNumber);
192
- int Consent_Status =
193
- (int)UMPConsentInformation.sharedInstance.consentStatus;
187
+ NSString *sdkVersion = GADGetStringFromVersionNumber(GADMobileAds.sharedInstance.versionNumber);
188
+ int Consent_Status = (int)UMPConsentInformation.sharedInstance.consentStatus;
189
+ int initAttStatus = (int)attStatus;
194
190
 
195
191
  NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
196
192
  NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
197
193
  NSNumber *CmpSdkID = [prefs valueForKey:@"IABTCF_CmpSdkID"];
198
194
  NSString *gdprApplies = [prefs stringForKey:@"IABTCF_gdprApplies"];
199
- NSString *PurposeConsents =
200
- [prefs stringForKey:@"IABTCF_PurposeConsents"];
195
+ NSString *PurposeConsents = [prefs stringForKey:@"IABTCF_PurposeConsents"];
201
196
  NSString *TCString = [prefs stringForKey:@"IABTCF_TCString"];
202
197
  NSString *additionalConsent = [prefs stringForKey:@"IABTCF_AddtlConsent"];
203
198
 
204
199
  result[@"version"] = sdkVersion;
205
200
  result[@"consentStatus"] = @(Consent_Status);
201
+ result[@"attStatus"] = @(initAttStatus);
206
202
  result[@"adapter"] = adaptersArray;
207
203
  result[@"CmpSdkID"] = CmpSdkID;
208
204
  result[@"gdprApplies"] = gdprApplies;
@@ -366,7 +362,7 @@ BOOL isUsingAdManagerRequest = YES;
366
362
  CDVPluginResult *pluginResult;
367
363
  NSString *callbackId = command.callbackId;
368
364
 
369
- if (isIAB == 1) {
365
+
370
366
  NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
371
367
  NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
372
368
 
@@ -386,9 +382,7 @@ BOOL isUsingAdManagerRequest = YES;
386
382
 
387
383
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:result];
388
384
  [self fireEvent:@"" event:@"onGetIabTfc" withData:nil];
389
- } else {
390
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
391
- }
385
+
392
386
 
393
387
  [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
394
388
  }
@@ -468,47 +462,33 @@ BOOL isUsingAdManagerRequest = YES;
468
462
  }
469
463
 
470
464
  - (void)pluginInitialize {
471
- [super pluginInitialize];
465
+ [super pluginInitialize];
472
466
 
473
- [[NSNotificationCenter defaultCenter]
474
- addObserver:self
475
- selector:@selector(orientationDidChange:)
476
- name:UIDeviceOrientationDidChangeNotification
477
- object:nil];
478
-
479
- isIAB = YES;
480
- NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
481
- NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
482
- NSNumber *CmpSdkID = [prefs valueForKey:@"IABTCF"
483
- @"_CmpSd"
484
- @"kID"];
485
- NSString *gdprApplies = [prefs stringForKey:@"IABTCF"
486
- @"_gdprA"
487
- @"pplie"
488
- @"s"];
489
- NSString *PurposeConsents = [prefs stringForKey:@"IABTCF"
490
- @"_Purpo"
491
- @"seCons"
492
- @"ents"];
493
- NSString *TCString = [prefs stringForKey:@"IABTCF"
494
- @"_TCStr"
495
- @"ing"];
496
- result[@"IABTCF_"
497
- @"CmpSdkID"] = CmpSdkID;
498
- result[@"IABTCF_"
499
- @"gdprApplies"] = gdprApplies;
500
- result[@"IABTCF_"
501
- @"PurposeCons"
502
- @"ents"] = PurposeConsents;
503
- result[@"IABTCF_"
504
- @"TCString"] = TCString;
505
- // NSLog(@"%@",
506
- // [[NSUserDefaults
507
- // standardUserDefaults]
508
- // dictionaryRepresentation]);
509
- [prefs synchronize];
467
+ [[NSNotificationCenter defaultCenter]
468
+ addObserver:self
469
+ selector:@selector(orientationDidChange:)
470
+ name:UIDeviceOrientationDidChangeNotification
471
+ object:nil];
472
+
473
+ NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
474
+ NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
475
+
476
+ NSNumber *CmpSdkID = [prefs valueForKey:@"IABTCF_CmpSdkID"];
477
+ NSString *gdprApplies = [prefs stringForKey:@"IABTCF_gdprApplies"];
478
+ NSString *PurposeConsents = [prefs stringForKey:@"IABTCF_PurposeConsents"];
479
+ NSString *TCString = [prefs stringForKey:@"IABTCF_TCString"];
480
+
481
+ result[@"IABTCF_CmpSdkID"] = CmpSdkID;
482
+ result[@"IABTCF_gdprApplies"] = gdprApplies;
483
+ result[@"IABTCF_PurposeConsents"] = PurposeConsents;
484
+ result[@"IABTCF_TCString"] = TCString;
485
+
486
+ // NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
487
+
488
+ [prefs synchronize];
510
489
  }
511
490
 
491
+
512
492
  - (void)orientationDidChange:(NSNotification *)notification {
513
493
  // NSLog(@"Orientation changed");
514
494
  [self fireEvent:@"" event:@"on.screen.rotated" withData:nil];
@@ -522,6 +502,8 @@ BOOL isUsingAdManagerRequest = YES;
522
502
  [self.bannerView removeFromSuperview];
523
503
  }
524
504
  }
505
+
506
+ [self setAdRequest];
525
507
 
526
508
  self.bannerViewLayout = [[UIView alloc] initWithFrame:CGRectZero];
527
509
  self.bannerViewLayout.translatesAutoresizingMaskIntoConstraints = NO;
@@ -549,7 +531,7 @@ BOOL isUsingAdManagerRequest = YES;
549
531
  rootView.frame.size.width)];
550
532
  self.bannerView.adUnitID = bannerSaveAdUnitId;
551
533
  self.bannerView.delegate = self;
552
- [self.bannerView loadRequest:[GADRequest request]];
534
+ [self.bannerView loadRequest:self.globalRequest];
553
535
 
554
536
  [self.bannerViewLayout addSubview:self.bannerView];
555
537
  [self.bannerViewLayout bringSubviewToFront:self.bannerView];
@@ -563,53 +545,11 @@ BOOL isUsingAdManagerRequest = YES;
563
545
  }
564
546
  }
565
547
 
566
- - (void)addBannerConstraints {
567
- self.bannerView.translatesAutoresizingMaskIntoConstraints = NO;
568
548
 
569
- // Tambahkan constraint berdasarkan posisi
570
- if ([Position isEqualToString:@"bottom-center"]) {
571
- [self.viewController.view addConstraints:@[
572
- [NSLayoutConstraint
573
- constraintWithItem:self.bannerView
574
- attribute:NSLayoutAttributeBottom
575
- relatedBy:NSLayoutRelationEqual
576
- toItem:self.viewController.view.safeAreaLayoutGuide
577
- attribute:NSLayoutAttributeBottom
578
- multiplier:1
579
- constant:0],
580
- [NSLayoutConstraint constraintWithItem:self.bannerView
581
- attribute:NSLayoutAttributeCenterX
582
- relatedBy:NSLayoutRelationEqual
583
- toItem:self.viewController.view
584
- attribute:NSLayoutAttributeCenterX
585
- multiplier:1
586
- constant:0]
587
- ]];
588
- } else if ([Position isEqualToString:@"top-center"]) {
589
- [self.viewController.view addConstraints:@[
590
- [NSLayoutConstraint
591
- constraintWithItem:self.bannerView
592
- attribute:NSLayoutAttributeTop
593
- relatedBy:NSLayoutRelationEqual
594
- toItem:self.viewController.view.safeAreaLayoutGuide
595
- attribute:NSLayoutAttributeTop
596
- multiplier:1
597
- constant:0],
598
- [NSLayoutConstraint constraintWithItem:self.bannerView
599
- attribute:NSLayoutAttributeCenterX
600
- relatedBy:NSLayoutRelationEqual
601
- toItem:self.viewController.view
602
- attribute:NSLayoutAttributeCenterX
603
- multiplier:1
604
- constant:0]
605
- ]];
606
- }
607
- }
608
549
 
609
550
  - (void)loadBannerAd:(CDVInvokedUrlCommand *)command {
610
551
  CDVPluginResult *pluginResult;
611
552
  NSString *callbackId = command.callbackId;
612
- adFormat = 3;
613
553
  NSDictionary *options = [command.arguments objectAtIndex:0];
614
554
  NSString *adUnitId = [options valueForKey:@"adUnitId"];
615
555
  NSString *position = [options valueForKey:@"position"];
@@ -620,6 +560,10 @@ BOOL isUsingAdManagerRequest = YES;
620
560
 
621
561
  bannerSaveAdUnitId = adUnitId;
622
562
 
563
+ setPosition = position;
564
+
565
+ adFormat = 5;
566
+
623
567
  if (adUnitId == nil || [adUnitId length] == 0) {
624
568
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
625
569
  messageAsString:@"Ad unit ID is required"];
@@ -628,17 +572,18 @@ BOOL isUsingAdManagerRequest = YES;
628
572
  }
629
573
 
630
574
  if (collapsible != nil && [collapsible length] > 0) {
631
- enableCollapsible = YES;
575
+ isCollapsible = YES;
632
576
  } else {
633
- enableCollapsible = NO;
577
+ isCollapsible = NO;
634
578
  }
635
579
 
636
580
  if (autoResize) {
637
-
638
581
  isAutoResize = YES;
639
582
  }
583
+
584
+ [self setAdRequest];
640
585
 
641
- if (adFormat == 3) {
586
+ if (adFormat == 5) {
642
587
  dispatch_async(dispatch_get_main_queue(), ^{
643
588
  UIView *parentView = [self.webView superview];
644
589
  CGRect frame = self.bannerView.frame;
@@ -649,28 +594,26 @@ BOOL isUsingAdManagerRequest = YES;
649
594
  }
650
595
 
651
596
  self.viewWidth = frame.size.width;
652
-
597
+
653
598
  auto_Show = autoShow;
654
599
  adWidth = self.viewWidth;
655
600
 
656
- Position = position;
657
-
658
- GADAdSize sizes = [self __AdSizeFromString:size];
659
- self.bannerView = [[GADBannerView alloc] initWithAdSize:sizes];
660
-
661
- GADRequest *request = [GADRequest request];
601
+ GADAdSize siz = [self __AdSizeFromString:size];
602
+ self.bannerView = [[GADBannerView alloc] initWithAdSize:siz];
603
+
662
604
  GADExtras *extras = [[GADExtras alloc] init];
663
605
 
664
- if (enableCollapsible) {
606
+ if (isCollapsible) {
665
607
  extras.additionalParameters = @{@"collapsible" : collapsible};
608
+
609
+ [self.globalRequest registerAdNetworkExtras:extras];
610
+
666
611
  }
667
612
 
668
- [request registerAdNetworkExtras:extras];
669
-
670
613
  self.bannerView.adUnitID = adUnitId;
671
614
  self.bannerView.rootViewController = self.viewController;
672
615
  self.bannerView.delegate = self;
673
- [self.bannerView loadRequest:request];
616
+ [self.bannerView loadRequest:self.globalRequest];
674
617
  self.bannerView.hidden = YES;
675
618
  [parentView addSubview:self.bannerView];
676
619
  [parentView bringSubviewToFront:self.bannerView];
@@ -685,6 +628,8 @@ BOOL isUsingAdManagerRequest = YES;
685
628
  [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
686
629
  }
687
630
 
631
+
632
+
688
633
  - (GADAdSize)__AdSizeFromString:(NSString *)size {
689
634
 
690
635
  if (self.viewWidth == 0) {
@@ -718,14 +663,7 @@ BOOL isUsingAdManagerRequest = YES;
718
663
  [self addBannerViewToView:command];
719
664
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
720
665
  } else {
721
- [self fireEvent:@""
722
- event:@"on."
723
- @"bann"
724
- @"er."
725
- @"fail"
726
- @"ed."
727
- @"show"
728
- withData:nil];
666
+ [self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
729
667
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
730
668
  }
731
669
  [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
@@ -734,7 +672,7 @@ BOOL isUsingAdManagerRequest = YES;
734
672
  - (void)addBannerViewToView:(CDVInvokedUrlCommand *)command {
735
673
  bannerView.translatesAutoresizingMaskIntoConstraints = NO;
736
674
  [self.viewController.view addSubview:bannerView];
737
- if ([Position isEqualToString:@"bottom-center"]) {
675
+ if ([setPosition isEqualToString:@"bottom-center"]) {
738
676
  [self.viewController.view addConstraints:@[
739
677
  [NSLayoutConstraint
740
678
  constraintWithItem:bannerView
@@ -752,7 +690,7 @@ BOOL isUsingAdManagerRequest = YES;
752
690
  multiplier:1
753
691
  constant:0]
754
692
  ]];
755
- } else if ([Position isEqualToString:@"top-center"]) {
693
+ } else if ([setPosition isEqualToString:@"top-center"]) {
756
694
 
757
695
  [self.viewController.view addConstraints:@[
758
696
  [NSLayoutConstraint
@@ -834,13 +772,15 @@ BOOL isUsingAdManagerRequest = YES;
834
772
  adFormat = 1;
835
773
  self.appOpenAd = nil;
836
774
 
775
+ [self setAdRequest];
776
+
837
777
  if (adFormat == 1) {
838
778
  dispatch_async(dispatch_get_main_queue(), ^{
839
- GADRequest *request = [GADRequest request];
779
+
840
780
  GADExtras *extras = [[GADExtras alloc] init];
841
- [request registerAdNetworkExtras:extras];
781
+ [self.globalRequest registerAdNetworkExtras:extras];
842
782
 
843
- [GADAppOpenAd loadWithAdUnitID:adUnitId request:request completionHandler:^(GADAppOpenAd *ad, NSError *error) {
783
+ [GADAppOpenAd loadWithAdUnitID:adUnitId request:self.globalRequest completionHandler:^(GADAppOpenAd *ad, NSError *error) {
844
784
  if (error) {
845
785
  // Send load error to event
846
786
  NSDictionary *errorData = @{@"error": error.localizedDescription ?: @"Unknown error"};
@@ -881,9 +821,6 @@ BOOL isUsingAdManagerRequest = YES;
881
821
  };
882
822
 
883
823
 
884
-
885
-
886
-
887
824
  if (auto_Show) {
888
825
  NSError *presentError = nil;
889
826
  if ([self.appOpenAd canPresentFromRootViewController:self.viewController error:&presentError]) {
@@ -899,7 +836,7 @@ BOOL isUsingAdManagerRequest = YES;
899
836
  }
900
837
 
901
838
 
902
- if (ResponseInfo) {
839
+ if (isResponseInfo) {
903
840
  GADResponseInfo *responseInfo = ad.responseInfo;
904
841
  NSMutableArray *adNetworkInfoArray = [NSMutableArray array];
905
842
 
@@ -950,18 +887,11 @@ BOOL isUsingAdManagerRequest = YES;
950
887
  [self.appOpenAd canPresentFromRootViewController:self.viewController
951
888
  error:nil]) {
952
889
  [self.appOpenAd presentFromRootViewController:self.viewController];
890
+ adFormat = 1;
953
891
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
954
892
  } else {
955
893
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
956
- [self fireEvent:@""
957
- event:@"on."
958
- @"appO"
959
- @"penA"
960
- @"d."
961
- @"fail"
962
- @"ed."
963
- @"show"
964
- withData:nil];
894
+ [self fireEvent:@"" event:@"on.appOpened.failed.show" withData:nil];
965
895
  }
966
896
  [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
967
897
  }
@@ -975,11 +905,11 @@ BOOL isUsingAdManagerRequest = YES;
975
905
 
976
906
  auto_Show = autoShow;
977
907
  adFormat = 2;
978
-
908
+ [self setAdRequest];
979
909
  if (adFormat == 2) {
980
910
  dispatch_async(dispatch_get_main_queue(), ^{
981
- GADRequest *request = [GADRequest request];
982
- [GADInterstitialAd loadWithAdUnitID:adUnitId request:request completionHandler:^(GADInterstitialAd *ad, NSError *error) {
911
+
912
+ [GADInterstitialAd loadWithAdUnitID:adUnitId request:self.globalRequest completionHandler:^(GADInterstitialAd *ad, NSError *error) {
983
913
  if (error) {
984
914
  // Send load error to event
985
915
  NSDictionary *errorData = @{@"error": error.localizedDescription ?: @"Unknown error"};
@@ -1028,14 +958,14 @@ BOOL isUsingAdManagerRequest = YES;
1028
958
  NSDictionary *errorData = @{@"error": presentError.localizedDescription ?: @"Unknown error"};
1029
959
  NSData *errorJsonData = [NSJSONSerialization dataWithJSONObject:errorData options:0 error:nil];
1030
960
  NSString *errorJsonString = [[NSString alloc] initWithData:errorJsonData encoding:NSUTF8StringEncoding];
1031
-
1032
961
  [self fireEvent:@"" event:@"on.interstitial.failed.show" withData:errorJsonString];
1033
962
  }
963
+ adFormat = 2;
1034
964
  }
1035
965
 
1036
966
 
1037
967
 
1038
- if (ResponseInfo) {
968
+ if (isResponseInfo) {
1039
969
  GADResponseInfo *responseInfo = ad.responseInfo;
1040
970
  NSMutableArray *adNetworkInfoArray = [NSMutableArray array];
1041
971
 
@@ -1085,6 +1015,7 @@ BOOL isUsingAdManagerRequest = YES;
1085
1015
  NSError *presentError = nil;
1086
1016
  if (self.interstitial && [self.interstitial canPresentFromRootViewController:self.viewController error:&presentError]) {
1087
1017
  [self.interstitial presentFromRootViewController:self.viewController];
1018
+ adFormat = 2;
1088
1019
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
1089
1020
  } else {
1090
1021
  // Send show error to event
@@ -1109,11 +1040,10 @@ BOOL isUsingAdManagerRequest = YES;
1109
1040
 
1110
1041
  auto_Show = autoShow;
1111
1042
  adFormat = 4;
1112
-
1043
+ [self setAdRequest];
1113
1044
  if (adFormat == 4) {
1114
1045
  dispatch_async(dispatch_get_main_queue(), ^{
1115
- GADRequest *request = [GADRequest request];
1116
- [GADRewardedInterstitialAd loadWithAdUnitID:adUnitId request:request completionHandler:^(GADRewardedInterstitialAd *ad, NSError *error) {
1046
+ [GADRewardedInterstitialAd loadWithAdUnitID:adUnitId request:self.globalRequest completionHandler:^(GADRewardedInterstitialAd *ad, NSError *error) {
1117
1047
  if (error) {
1118
1048
  // Send error data to event
1119
1049
  NSDictionary *errorData = @{@"error": error.localizedDescription ?: @"Unknown error"};
@@ -1130,7 +1060,6 @@ BOOL isUsingAdManagerRequest = YES;
1130
1060
  [self fireEvent:@"" event:@"on.rewardedInt.loaded" withData:nil];
1131
1061
 
1132
1062
 
1133
-
1134
1063
  __weak __typeof(self) weakSelf = self;
1135
1064
  self.rewardedInterstitialAd.paidEventHandler = ^(GADAdValue *_Nonnull value) {
1136
1065
  __strong __typeof(weakSelf) strongSelf = weakSelf;
@@ -1168,9 +1097,9 @@ BOOL isUsingAdManagerRequest = YES;
1168
1097
  };
1169
1098
  NSData *rewardJsonData = [NSJSONSerialization dataWithJSONObject:rewardData options:0 error:nil];
1170
1099
  NSString *rewardJsonString = [[NSString alloc] initWithData:rewardJsonData encoding:NSUTF8StringEncoding];
1171
-
1172
- [self fireEvent:@"" event:@"on.rewardedInt.userEarnedReward" withData:rewardJsonString];
1100
+ adFormat = 4;
1173
1101
  isAdSkip = 2;
1102
+ [self fireEvent:@"" event:@"on.rewardedInt.userEarnedReward" withData:rewardJsonString];
1174
1103
  NSLog(@"Reward received with currency %@, amount %ld", reward.type, [reward.amount longValue]);
1175
1104
  }];
1176
1105
  } else {
@@ -1183,7 +1112,7 @@ BOOL isUsingAdManagerRequest = YES;
1183
1112
  }
1184
1113
 
1185
1114
 
1186
- if (ResponseInfo) {
1115
+ if (isResponseInfo) {
1187
1116
  GADResponseInfo *responseInfo = ad.responseInfo;
1188
1117
  NSMutableArray *adNetworkInfoArray = [NSMutableArray array];
1189
1118
 
@@ -1216,9 +1145,6 @@ BOOL isUsingAdManagerRequest = YES;
1216
1145
  }
1217
1146
  }
1218
1147
 
1219
-
1220
-
1221
-
1222
1148
  }
1223
1149
  }];
1224
1150
  });
@@ -1246,9 +1172,9 @@ BOOL isUsingAdManagerRequest = YES;
1246
1172
  };
1247
1173
  NSData *rewardJsonData = [NSJSONSerialization dataWithJSONObject:rewardData options:0 error:nil];
1248
1174
  NSString *rewardJsonString = [[NSString alloc] initWithData:rewardJsonData encoding:NSUTF8StringEncoding];
1249
-
1250
- [self fireEvent:@"" event:@"on.rewardedInt.userEarnedReward" withData:rewardJsonString];
1251
1175
  isAdSkip = 2;
1176
+ adFormat = 4;
1177
+ [self fireEvent:@"" event:@"on.rewardedInt.userEarnedReward" withData:rewardJsonString];
1252
1178
  NSLog(@"Reward received with currency %@, amount %ld", reward.type, [reward.amount longValue]);
1253
1179
  }];
1254
1180
 
@@ -1274,12 +1200,10 @@ BOOL isUsingAdManagerRequest = YES;
1274
1200
  BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
1275
1201
  auto_Show = autoShow;
1276
1202
  adFormat = 3;
1277
-
1203
+ [self setAdRequest];
1278
1204
  if (adFormat == 3) {
1279
1205
  dispatch_async(dispatch_get_main_queue(), ^{
1280
- GADRequest *request = [GADRequest request];
1281
-
1282
- [GADRewardedAd loadWithAdUnitID:adUnitId request:request completionHandler:^(GADRewardedAd *ad, NSError *error) {
1206
+ [GADRewardedAd loadWithAdUnitID:adUnitId request:self.globalRequest completionHandler:^(GADRewardedAd *ad, NSError *error) {
1283
1207
  if (error) {
1284
1208
  NSDictionary *errorData = @{@"error": error.localizedDescription ?: @"Unknown error"};
1285
1209
  NSData *jsonData = [NSJSONSerialization dataWithJSONObject:errorData options:0 error:nil];
@@ -1289,7 +1213,6 @@ BOOL isUsingAdManagerRequest = YES;
1289
1213
  }
1290
1214
 
1291
1215
  self.rewardedAd = ad;
1292
-
1293
1216
  isAdSkip = 0;
1294
1217
  self.rewardedAd.fullScreenContentDelegate = self;
1295
1218
  [self fireEvent:@"" event:@"on.rewarded.loaded" withData:nil];
@@ -1297,17 +1220,14 @@ BOOL isUsingAdManagerRequest = YES;
1297
1220
  __weak __typeof(self) weakSelf = self;
1298
1221
  self.rewardedAd.paidEventHandler = ^(GADAdValue *_Nonnull value) {
1299
1222
  __strong __typeof(weakSelf) strongSelf = weakSelf;
1300
- if (!strongSelf) return; // Pastikan strongSelf tidak null
1223
+ if (!strongSelf) return;
1301
1224
 
1302
- // Mengambil data ad revenue
1303
1225
  NSDecimalNumber *adValue = value.value;
1304
1226
  NSString *currencyCode = value.currencyCode;
1305
1227
  GADAdValuePrecision precision = value.precision;
1306
1228
 
1307
- // Mendapatkan ID unit iklan
1308
1229
  NSString *adUnitId = strongSelf.rewardedAd.adUnitID;
1309
1230
 
1310
- // Mengirim data dalam format JSON
1311
1231
  NSDictionary *data = @{
1312
1232
  @"value": adValue,
1313
1233
  @"currencyCode": currencyCode,
@@ -1327,17 +1247,16 @@ BOOL isUsingAdManagerRequest = YES;
1327
1247
  if ([self.rewardedAd canPresentFromRootViewController:self.viewController error:&presentError]) {
1328
1248
  [self.rewardedAd presentFromRootViewController:self.viewController userDidEarnRewardHandler:^{
1329
1249
  GADAdReward *reward = self.rewardedAd.adReward;
1330
-
1250
+ adFormat = 3;
1331
1251
  NSDictionary *rewardData = @{
1332
1252
  @"rewardType": reward.type,
1333
1253
  @"rewardAmount": [reward.amount stringValue]
1334
1254
  };
1335
1255
  NSData *rewardJsonData = [NSJSONSerialization dataWithJSONObject:rewardData options:0 error:nil];
1336
1256
  NSString *rewardJsonString = [[NSString alloc] initWithData:rewardJsonData encoding:NSUTF8StringEncoding];
1337
-
1338
- [self fireEvent:@"" event:@"on.reward.userEarnedReward" withData:rewardJsonString];
1339
1257
  isAdSkip = 2;
1340
- // NSLog(@"Reward diterima dengan currency %@, amount %lf", reward.type, [reward.amount doubleValue]);
1258
+ [self fireEvent:@"" event:@"on.reward.userEarnedReward" withData:rewardJsonString];
1259
+
1341
1260
  }];
1342
1261
  } else {
1343
1262
  NSDictionary *errorData = @{@"error": presentError.localizedDescription ?: @"Unknown error"};
@@ -1347,7 +1266,7 @@ BOOL isUsingAdManagerRequest = YES;
1347
1266
  }
1348
1267
 
1349
1268
 
1350
- if (ResponseInfo) {
1269
+ if (isResponseInfo) {
1351
1270
  GADResponseInfo *responseInfo = ad.responseInfo;
1352
1271
  NSMutableArray *adNetworkInfoArray = [NSMutableArray array];
1353
1272
 
@@ -1416,7 +1335,7 @@ BOOL isUsingAdManagerRequest = YES;
1416
1335
  }
1417
1336
 
1418
1337
  isAdSkip = 2;
1419
-
1338
+ adFormat = 3;
1420
1339
 
1421
1340
  NSLog(@"Reward received with currency %@, amount %lf", reward.type, [reward.amount doubleValue]);
1422
1341
  }];
@@ -1514,9 +1433,10 @@ BOOL isUsingAdManagerRequest = YES;
1514
1433
  return hexString;
1515
1434
  }
1516
1435
 
1517
- #pragma mark GADBannerViewDelegate implementation
1436
+ #pragma mark GADBannerViewDelegate implementation
1518
1437
 
1519
1438
  - (void)bannerViewDidReceiveAd:(GADBannerView *)bannerView {
1439
+ // NSLog(@"The last loaded banner is %@collapsible.", (bannerView.isCollapsible ? @"" : @"not "));
1520
1440
  NSString *collapsibleStatus = bannerView.isCollapsible ? @"collapsible" : @"not collapsible";
1521
1441
  NSDictionary *eventData = @{@"collapsible" : collapsibleStatus};
1522
1442
  NSError *error;
@@ -1529,7 +1449,6 @@ BOOL isUsingAdManagerRequest = YES;
1529
1449
 
1530
1450
  [self fireEvent:@"" event:@"on.banner.load" withData:nil];
1531
1451
 
1532
-
1533
1452
  if (auto_Show && self.bannerView) {
1534
1453
  [self addBannerViewToView:command];
1535
1454
  self.bannerView.hidden = NO;
@@ -1563,10 +1482,7 @@ BOOL isUsingAdManagerRequest = YES;
1563
1482
 
1564
1483
 
1565
1484
 
1566
-
1567
-
1568
-
1569
- if (ResponseInfo) {
1485
+ if (isResponseInfo) {
1570
1486
  GADResponseInfo *responseInfo = self.bannerView.responseInfo;
1571
1487
  NSMutableArray *adNetworkInfoArray = [NSMutableArray array];
1572
1488
 
@@ -1637,19 +1553,23 @@ BOOL isUsingAdManagerRequest = YES;
1637
1553
  [self fireEvent:@"" event:@"on.banner.did.dismiss" withData:nil];
1638
1554
  }
1639
1555
 
1640
- #pragma GADFullScreeContentDelegate implementation
1556
+ #pragma mark GADFullScreeContentDelegate implementation
1641
1557
 
1642
1558
  - (void)adWillPresentFullScreenContent:(id)ad {
1643
1559
  if (adFormat == 1) {
1560
+ adFormat = 1;
1644
1561
  [self fireEvent:@"" event:@"on.appOpenAd.show" withData:nil];
1645
1562
  } else if (adFormat == 2) {
1563
+ adFormat = 2;
1646
1564
  [self fireEvent:@"" event:@"on.interstitial.show" withData:nil];
1647
1565
  [self fireEvent:@"" event:@"onPresentAd" withData:nil];
1648
1566
  } else if (adFormat == 3) {
1567
+ adFormat = 3;
1649
1568
  [self fireEvent:@"" event:@"on.rewarded.show" withData:nil];
1650
1569
  isAdSkip = 1;
1651
1570
  } else if (adFormat == 4) {
1652
1571
  isAdSkip = 1;
1572
+ adFormat = 4;
1653
1573
  [self fireEvent:@"" event:@"on.rewardedInt.showed" withData:nil];
1654
1574
  }
1655
1575
  }
@@ -1682,15 +1602,17 @@ BOOL isUsingAdManagerRequest = YES;
1682
1602
  } else if (adFormat == 2) {
1683
1603
  [self fireEvent:@"" event:@"on.interstitial.dismissed" withData:nil];
1684
1604
  } else if (adFormat == 3) {
1685
- [self fireEvent:@"" event:@"on.rewarded.dismissed" withData:nil];
1686
1605
  if (isAdSkip != 2) {
1687
1606
  [self fireEvent:@"" event:@"on.rewarded.ad.skip" withData:nil];
1607
+ } else {
1608
+ [self fireEvent:@"" event:@"on.rewarded.dismissed" withData:nil];
1688
1609
  }
1689
1610
  } else if (adFormat == 4) {
1690
1611
  if (isAdSkip != 2) {
1691
1612
  [self fireEvent:@"" event:@"on.rewardedInt.ad.skip" withData:nil];
1613
+ } else {
1614
+ [self fireEvent:@"" event:@"on.rewardedInt.dismissed" withData:nil];
1692
1615
  }
1693
- [self fireEvent:@"" event:@"on.rewardedInt.dismissed" withData:nil];
1694
1616
  }
1695
1617
  }
1696
1618