emi-indo-cordova-plugin-admob 1.6.3 → 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/example/package.json +1 -1
- package/example/www/index.html +4 -0
- package/example/www/js/rewardedInterstitialAd.js +124 -0
- package/package.json +1 -1
- package/plugin.xml +1 -1
- package/src/android/emiAdmobPlugin.kt +43 -67
- package/src/ios/emiAdmobPlugin.m +21 -67
package/example/package.json
CHANGED
package/example/www/index.html
CHANGED
@@ -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>
|
@@ -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
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.
|
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>
|
@@ -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
|
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
|
-
|
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
|
-
|
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
|
+
|
package/src/ios/emiAdmobPlugin.m
CHANGED
@@ -547,55 +547,6 @@ BOOL isUsingAdManagerRequest = YES;
|
|
547
547
|
|
548
548
|
|
549
549
|
|
550
|
-
|
551
|
-
/*
|
552
|
-
|
553
|
-
- (void)addBannerConstraints {
|
554
|
-
self.bannerView.translatesAutoresizingMaskIntoConstraints = NO;
|
555
|
-
|
556
|
-
if ([setPosition isEqualToString:@"bottom-center"]) {
|
557
|
-
[self.viewController.view addConstraints:@[
|
558
|
-
[NSLayoutConstraint
|
559
|
-
constraintWithItem:self.bannerView
|
560
|
-
attribute:NSLayoutAttributeBottom
|
561
|
-
relatedBy:NSLayoutRelationEqual
|
562
|
-
toItem:self.viewController.view.safeAreaLayoutGuide
|
563
|
-
attribute:NSLayoutAttributeBottom
|
564
|
-
multiplier:1
|
565
|
-
constant:0],
|
566
|
-
[NSLayoutConstraint constraintWithItem:self.bannerView
|
567
|
-
attribute:NSLayoutAttributeCenterX
|
568
|
-
relatedBy:NSLayoutRelationEqual
|
569
|
-
toItem:self.viewController.view
|
570
|
-
attribute:NSLayoutAttributeCenterX
|
571
|
-
multiplier:1
|
572
|
-
constant:0]
|
573
|
-
]];
|
574
|
-
} else if ([setPosition isEqualToString:@"top-center"]) {
|
575
|
-
[self.viewController.view addConstraints:@[
|
576
|
-
[NSLayoutConstraint
|
577
|
-
constraintWithItem:self.bannerView
|
578
|
-
attribute:NSLayoutAttributeTop
|
579
|
-
relatedBy:NSLayoutRelationEqual
|
580
|
-
toItem:self.viewController.view.safeAreaLayoutGuide
|
581
|
-
attribute:NSLayoutAttributeTop
|
582
|
-
multiplier:1
|
583
|
-
constant:0],
|
584
|
-
[NSLayoutConstraint constraintWithItem:self.bannerView
|
585
|
-
attribute:NSLayoutAttributeCenterX
|
586
|
-
relatedBy:NSLayoutRelationEqual
|
587
|
-
toItem:self.viewController.view
|
588
|
-
attribute:NSLayoutAttributeCenterX
|
589
|
-
multiplier:1
|
590
|
-
constant:0]
|
591
|
-
]];
|
592
|
-
}
|
593
|
-
}
|
594
|
-
|
595
|
-
*/
|
596
|
-
|
597
|
-
|
598
|
-
|
599
550
|
- (void)loadBannerAd:(CDVInvokedUrlCommand *)command {
|
600
551
|
CDVPluginResult *pluginResult;
|
601
552
|
NSString *callbackId = command.callbackId;
|
@@ -611,7 +562,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
611
562
|
|
612
563
|
setPosition = position;
|
613
564
|
|
614
|
-
adFormat =
|
565
|
+
adFormat = 5;
|
615
566
|
|
616
567
|
if (adUnitId == nil || [adUnitId length] == 0) {
|
617
568
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
|
@@ -623,7 +574,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
623
574
|
if (collapsible != nil && [collapsible length] > 0) {
|
624
575
|
isCollapsible = YES;
|
625
576
|
} else {
|
626
|
-
isCollapsible =
|
577
|
+
isCollapsible = NO;
|
627
578
|
}
|
628
579
|
|
629
580
|
if (autoResize) {
|
@@ -632,7 +583,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
632
583
|
|
633
584
|
[self setAdRequest];
|
634
585
|
|
635
|
-
if (adFormat ==
|
586
|
+
if (adFormat == 5) {
|
636
587
|
dispatch_async(dispatch_get_main_queue(), ^{
|
637
588
|
UIView *parentView = [self.webView superview];
|
638
589
|
CGRect frame = self.bannerView.frame;
|
@@ -936,6 +887,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
936
887
|
[self.appOpenAd canPresentFromRootViewController:self.viewController
|
937
888
|
error:nil]) {
|
938
889
|
[self.appOpenAd presentFromRootViewController:self.viewController];
|
890
|
+
adFormat = 1;
|
939
891
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
940
892
|
} else {
|
941
893
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
@@ -1006,9 +958,9 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1006
958
|
NSDictionary *errorData = @{@"error": presentError.localizedDescription ?: @"Unknown error"};
|
1007
959
|
NSData *errorJsonData = [NSJSONSerialization dataWithJSONObject:errorData options:0 error:nil];
|
1008
960
|
NSString *errorJsonString = [[NSString alloc] initWithData:errorJsonData encoding:NSUTF8StringEncoding];
|
1009
|
-
|
1010
961
|
[self fireEvent:@"" event:@"on.interstitial.failed.show" withData:errorJsonString];
|
1011
962
|
}
|
963
|
+
adFormat = 2;
|
1012
964
|
}
|
1013
965
|
|
1014
966
|
|
@@ -1063,6 +1015,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1063
1015
|
NSError *presentError = nil;
|
1064
1016
|
if (self.interstitial && [self.interstitial canPresentFromRootViewController:self.viewController error:&presentError]) {
|
1065
1017
|
[self.interstitial presentFromRootViewController:self.viewController];
|
1018
|
+
adFormat = 2;
|
1066
1019
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1067
1020
|
} else {
|
1068
1021
|
// Send show error to event
|
@@ -1144,9 +1097,9 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1144
1097
|
};
|
1145
1098
|
NSData *rewardJsonData = [NSJSONSerialization dataWithJSONObject:rewardData options:0 error:nil];
|
1146
1099
|
NSString *rewardJsonString = [[NSString alloc] initWithData:rewardJsonData encoding:NSUTF8StringEncoding];
|
1147
|
-
|
1148
|
-
[self fireEvent:@"" event:@"on.rewardedInt.userEarnedReward" withData:rewardJsonString];
|
1100
|
+
adFormat = 4;
|
1149
1101
|
isAdSkip = 2;
|
1102
|
+
[self fireEvent:@"" event:@"on.rewardedInt.userEarnedReward" withData:rewardJsonString];
|
1150
1103
|
NSLog(@"Reward received with currency %@, amount %ld", reward.type, [reward.amount longValue]);
|
1151
1104
|
}];
|
1152
1105
|
} else {
|
@@ -1219,9 +1172,9 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1219
1172
|
};
|
1220
1173
|
NSData *rewardJsonData = [NSJSONSerialization dataWithJSONObject:rewardData options:0 error:nil];
|
1221
1174
|
NSString *rewardJsonString = [[NSString alloc] initWithData:rewardJsonData encoding:NSUTF8StringEncoding];
|
1222
|
-
|
1223
|
-
[self fireEvent:@"" event:@"on.rewardedInt.userEarnedReward" withData:rewardJsonString];
|
1224
1175
|
isAdSkip = 2;
|
1176
|
+
adFormat = 4;
|
1177
|
+
[self fireEvent:@"" event:@"on.rewardedInt.userEarnedReward" withData:rewardJsonString];
|
1225
1178
|
NSLog(@"Reward received with currency %@, amount %ld", reward.type, [reward.amount longValue]);
|
1226
1179
|
}];
|
1227
1180
|
|
@@ -1260,7 +1213,6 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1260
1213
|
}
|
1261
1214
|
|
1262
1215
|
self.rewardedAd = ad;
|
1263
|
-
|
1264
1216
|
isAdSkip = 0;
|
1265
1217
|
self.rewardedAd.fullScreenContentDelegate = self;
|
1266
1218
|
[self fireEvent:@"" event:@"on.rewarded.loaded" withData:nil];
|
@@ -1295,16 +1247,15 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1295
1247
|
if ([self.rewardedAd canPresentFromRootViewController:self.viewController error:&presentError]) {
|
1296
1248
|
[self.rewardedAd presentFromRootViewController:self.viewController userDidEarnRewardHandler:^{
|
1297
1249
|
GADAdReward *reward = self.rewardedAd.adReward;
|
1298
|
-
|
1250
|
+
adFormat = 3;
|
1299
1251
|
NSDictionary *rewardData = @{
|
1300
1252
|
@"rewardType": reward.type,
|
1301
1253
|
@"rewardAmount": [reward.amount stringValue]
|
1302
1254
|
};
|
1303
1255
|
NSData *rewardJsonData = [NSJSONSerialization dataWithJSONObject:rewardData options:0 error:nil];
|
1304
1256
|
NSString *rewardJsonString = [[NSString alloc] initWithData:rewardJsonData encoding:NSUTF8StringEncoding];
|
1305
|
-
|
1306
|
-
[self fireEvent:@"" event:@"on.reward.userEarnedReward" withData:rewardJsonString];
|
1307
1257
|
isAdSkip = 2;
|
1258
|
+
[self fireEvent:@"" event:@"on.reward.userEarnedReward" withData:rewardJsonString];
|
1308
1259
|
|
1309
1260
|
}];
|
1310
1261
|
} else {
|
@@ -1384,7 +1335,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1384
1335
|
}
|
1385
1336
|
|
1386
1337
|
isAdSkip = 2;
|
1387
|
-
|
1338
|
+
adFormat = 3;
|
1388
1339
|
|
1389
1340
|
NSLog(@"Reward received with currency %@, amount %lf", reward.type, [reward.amount doubleValue]);
|
1390
1341
|
}];
|
@@ -1531,9 +1482,6 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1531
1482
|
|
1532
1483
|
|
1533
1484
|
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
1485
|
if (isResponseInfo) {
|
1538
1486
|
GADResponseInfo *responseInfo = self.bannerView.responseInfo;
|
1539
1487
|
NSMutableArray *adNetworkInfoArray = [NSMutableArray array];
|
@@ -1609,15 +1557,19 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1609
1557
|
|
1610
1558
|
- (void)adWillPresentFullScreenContent:(id)ad {
|
1611
1559
|
if (adFormat == 1) {
|
1560
|
+
adFormat = 1;
|
1612
1561
|
[self fireEvent:@"" event:@"on.appOpenAd.show" withData:nil];
|
1613
1562
|
} else if (adFormat == 2) {
|
1563
|
+
adFormat = 2;
|
1614
1564
|
[self fireEvent:@"" event:@"on.interstitial.show" withData:nil];
|
1615
1565
|
[self fireEvent:@"" event:@"onPresentAd" withData:nil];
|
1616
1566
|
} else if (adFormat == 3) {
|
1567
|
+
adFormat = 3;
|
1617
1568
|
[self fireEvent:@"" event:@"on.rewarded.show" withData:nil];
|
1618
1569
|
isAdSkip = 1;
|
1619
1570
|
} else if (adFormat == 4) {
|
1620
1571
|
isAdSkip = 1;
|
1572
|
+
adFormat = 4;
|
1621
1573
|
[self fireEvent:@"" event:@"on.rewardedInt.showed" withData:nil];
|
1622
1574
|
}
|
1623
1575
|
}
|
@@ -1650,15 +1602,17 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1650
1602
|
} else if (adFormat == 2) {
|
1651
1603
|
[self fireEvent:@"" event:@"on.interstitial.dismissed" withData:nil];
|
1652
1604
|
} else if (adFormat == 3) {
|
1653
|
-
[self fireEvent:@"" event:@"on.rewarded.dismissed" withData:nil];
|
1654
1605
|
if (isAdSkip != 2) {
|
1655
1606
|
[self fireEvent:@"" event:@"on.rewarded.ad.skip" withData:nil];
|
1607
|
+
} else {
|
1608
|
+
[self fireEvent:@"" event:@"on.rewarded.dismissed" withData:nil];
|
1656
1609
|
}
|
1657
1610
|
} else if (adFormat == 4) {
|
1658
1611
|
if (isAdSkip != 2) {
|
1659
1612
|
[self fireEvent:@"" event:@"on.rewardedInt.ad.skip" withData:nil];
|
1613
|
+
} else {
|
1614
|
+
[self fireEvent:@"" event:@"on.rewardedInt.dismissed" withData:nil];
|
1660
1615
|
}
|
1661
|
-
[self fireEvent:@"" event:@"on.rewardedInt.dismissed" withData:nil];
|
1662
1616
|
}
|
1663
1617
|
}
|
1664
1618
|
|