emi-indo-cordova-plugin-admob 1.5.3 → 1.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +1 -5
- package/README.md +42 -148
- package/example/www/css/index.css +110 -0
- package/example/www/index.html +27 -0
- package/example/www/js/appOpenAd.js +146 -0
- package/example/www/js/bannerAd.js +156 -0
- package/example/www/js/deviceready.js +110 -0
- package/example/www/js/interstitialAd.js +123 -0
- package/example/www/js/rewardedAd.js +125 -0
- package/package.json +2 -2
- package/plugin.xml +4 -5
- package/src/android/emiAdmobPlugin.kt +839 -695
- package/src/ios/emiAdmobPlugin.m +898 -974
- package/www/emiAdmobPlugin.js +4 -4
@@ -1,5 +1,4 @@
|
|
1
1
|
package emi.indo.cordova.plugin.admob
|
2
|
-
import android.R
|
3
2
|
import android.annotation.SuppressLint
|
4
3
|
import android.app.Activity
|
5
4
|
import android.content.Context
|
@@ -154,34 +153,37 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
154
153
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.screen.rotated');")
|
155
154
|
isOrientation = orientation
|
156
155
|
if (this.isAutoResize) {
|
157
|
-
mActivity
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
FrameLayout.LayoutParams
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
156
|
+
if(mActivity != null) {
|
157
|
+
mActivity!!.runOnUiThread {
|
158
|
+
try {
|
159
|
+
if (bannerViewLayout != null && bannerView != null) {
|
160
|
+
val parentView = bannerViewLayout!!.parent as ViewGroup
|
161
|
+
parentView.removeView(bannerViewLayout)
|
162
|
+
bannerViewLayout = FrameLayout(mActivity!!)
|
163
|
+
val params = FrameLayout.LayoutParams(
|
164
|
+
FrameLayout.LayoutParams.MATCH_PARENT,
|
165
|
+
FrameLayout.LayoutParams.WRAP_CONTENT
|
166
|
+
)
|
167
|
+
val rootView =
|
168
|
+
mActivity!!.window.decorView.findViewById<View>(View.generateViewId())
|
169
|
+
if (rootView is ViewGroup) {
|
170
|
+
rootView.addView(bannerViewLayout, params)
|
171
|
+
} else {
|
172
|
+
mActivity!!.addContentView(bannerViewLayout, params)
|
173
|
+
}
|
174
|
+
bannerView = AdView(mContext!!)
|
175
|
+
setBannerPosition(this.isPosition)
|
176
|
+
setBannerSiz(this.isSize)
|
177
|
+
bannerView!!.adUnitId = bannerAdUnitId!!
|
178
|
+
bannerView!!.adListener = bannerAdListener
|
179
|
+
bannerView!!.loadAd(buildAdRequest())
|
180
|
+
adjustWebViewForBanner(this.isPosition)
|
181
|
+
bannerViewLayout!!.addView(bannerView)
|
182
|
+
bannerViewLayout!!.bringToFront()
|
172
183
|
}
|
173
|
-
|
174
|
-
|
175
|
-
setBannerSiz(this.isSize)
|
176
|
-
bannerView!!.adUnitId = bannerAdUnitId!!
|
177
|
-
bannerView!!.adListener = bannerAdListener
|
178
|
-
bannerView!!.loadAd(buildAdRequest())
|
179
|
-
adjustWebViewForBanner(this.isPosition)
|
180
|
-
bannerViewLayout!!.addView(bannerView)
|
181
|
-
bannerViewLayout!!.bringToFront()
|
184
|
+
} catch (e: Exception) {
|
185
|
+
PUBLIC_CALLBACKS!!.error("Error adjusting banner size: " + e.message)
|
182
186
|
}
|
183
|
-
} catch (e: Exception) {
|
184
|
-
PUBLIC_CALLBACKS!!.error("Error adjusting banner size: " + e.message)
|
185
187
|
}
|
186
188
|
}
|
187
189
|
}
|
@@ -214,456 +216,535 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
214
216
|
|
215
217
|
if (action == "initialize") {
|
216
218
|
val options = args.getJSONObject(0)
|
217
|
-
mActivity
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
.
|
230
|
-
|
219
|
+
if(mActivity != null) {
|
220
|
+
mActivity!!.runOnUiThread {
|
221
|
+
val setAdRequest = options.optBoolean("isUsingAdManagerRequest")
|
222
|
+
val responseInfo = options.optBoolean("isResponseInfo")
|
223
|
+
val setDebugGeography = options.optBoolean("isConsentDebug")
|
224
|
+
setUsingAdManagerRequest(setAdRequest)
|
225
|
+
this.isResponseInfo = responseInfo
|
226
|
+
this.setDebugGeography = setDebugGeography
|
227
|
+
val params: ConsentRequestParameters
|
228
|
+
if (this.setDebugGeography) {
|
229
|
+
val debugSettings = mActivity?.let {
|
230
|
+
deviceId?.let { it1 ->
|
231
|
+
ConsentDebugSettings.Builder(it)
|
232
|
+
.setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA)
|
233
|
+
.addTestDeviceHashedId(it1).build()
|
234
|
+
}
|
231
235
|
}
|
236
|
+
params = ConsentRequestParameters.Builder()
|
237
|
+
.setConsentDebugSettings(debugSettings).build()
|
238
|
+
} else {
|
239
|
+
params = ConsentRequestParameters.Builder()
|
240
|
+
.setTagForUnderAgeOfConsent(this.isSetTagForUnderAgeOfConsent).build()
|
232
241
|
}
|
233
|
-
params = ConsentRequestParameters.Builder()
|
234
|
-
.setConsentDebugSettings(debugSettings).build()
|
235
|
-
} else {
|
236
|
-
params = ConsentRequestParameters.Builder()
|
237
|
-
.setTagForUnderAgeOfConsent(this.isSetTagForUnderAgeOfConsent).build()
|
238
|
-
}
|
239
242
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
243
|
+
consentInformation =
|
244
|
+
mContext?.let { UserMessagingPlatform.getConsentInformation(it) }
|
245
|
+
mActivity?.let {
|
246
|
+
consentInformation?.requestConsentInfoUpdate(
|
247
|
+
it,
|
248
|
+
params,
|
249
|
+
{
|
250
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.info.update');")
|
251
|
+
when (consentInformation!!.getConsentStatus()) {
|
252
|
+
ConsentInformation.ConsentStatus.NOT_REQUIRED -> cWebView!!.loadUrl(
|
253
|
+
"javascript:cordova.fireDocumentEvent('on.consent.status.not_required');"
|
254
|
+
)
|
255
|
+
|
256
|
+
ConsentInformation.ConsentStatus.OBTAINED -> cWebView!!.loadUrl(
|
257
|
+
"javascript:cordova.fireDocumentEvent('on.consent.status.obtained');"
|
258
|
+
)
|
259
|
+
|
260
|
+
ConsentInformation.ConsentStatus.REQUIRED -> {
|
261
|
+
handleConsentForm()
|
262
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.required');")
|
263
|
+
}
|
254
264
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
265
|
+
ConsentInformation.ConsentStatus.UNKNOWN -> cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.unknown');")
|
266
|
+
}
|
267
|
+
},
|
268
|
+
{ formError: FormError ->
|
269
|
+
if (consentInformation!!.canRequestAds()) {
|
270
|
+
initializeMobileAdsSdk()
|
271
|
+
}
|
272
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.info.update.failed', { message: '" + formError.message + "' });")
|
273
|
+
})
|
274
|
+
}
|
275
|
+
if (consentInformation?.canRequestAds()!!) {
|
276
|
+
initializeMobileAdsSdk()
|
277
|
+
}
|
267
278
|
}
|
268
279
|
}
|
269
280
|
|
270
281
|
return true
|
271
282
|
} else if (action == "targeting") {
|
272
283
|
val options = args.getJSONObject(0)
|
273
|
-
mActivity
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
284
|
+
if(mActivity != null) {
|
285
|
+
mActivity!!.runOnUiThread {
|
286
|
+
try {
|
287
|
+
val childDirectedTreatment = options.optBoolean("childDirectedTreatment")
|
288
|
+
val underAgeOfConsent = options.optBoolean("underAgeOfConsent")
|
289
|
+
val contentRating = options.optString("contentRating")
|
290
|
+
this.isSetTagForChildDirectedTreatment = childDirectedTreatment
|
291
|
+
this.isSetTagForUnderAgeOfConsent = underAgeOfConsent
|
292
|
+
this.isSetMaxAdContentRating = contentRating
|
293
|
+
targeting(childDirectedTreatment, underAgeOfConsent, contentRating)
|
294
|
+
callbackContext.success();
|
295
|
+
} catch (e: Exception) {
|
296
|
+
callbackContext.error("Error: " + e.message)
|
297
|
+
}
|
285
298
|
}
|
286
299
|
}
|
287
300
|
return true
|
288
301
|
} else if (action == "targetingAdRequest") {
|
289
302
|
val options = args.getJSONObject(0)
|
290
|
-
mActivity
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
303
|
+
if(mActivity != null) {
|
304
|
+
mActivity!!.runOnUiThread {
|
305
|
+
val customTargetingEnabled = options.optBoolean("customTargetingEnabled")
|
306
|
+
val categoryExclusionsEnabled = options.optBoolean("categoryExclusionsEnabled")
|
307
|
+
val ppIdEnabled = options.optBoolean("ppIdEnabled")
|
308
|
+
val contentURLEnabled = options.optBoolean("contentURLEnabled")
|
309
|
+
val brandSafetyEnabled = options.optBoolean("brandSafetyEnabled")
|
310
|
+
|
311
|
+
val customTargeting = options.optJSONArray("customTargetingValue")
|
312
|
+
val categoryExclusions = options.optString("categoryExclusionsValue")
|
313
|
+
val ppId = options.optString("ppIdValue")
|
314
|
+
val ctURL = options.optString("contentURLValue")
|
315
|
+
val brandSafetyArr = options.optJSONArray("brandSafetyArr")
|
316
|
+
try {
|
317
|
+
this.customTargetingEnabled = customTargetingEnabled
|
318
|
+
this.categoryExclusionsEnabled = categoryExclusionsEnabled
|
319
|
+
this.ppIdEnabled = ppIdEnabled
|
320
|
+
this.contentURLEnabled = contentURLEnabled
|
321
|
+
this.brandSafetyEnabled = brandSafetyEnabled
|
322
|
+
this.cExclusionsValue = categoryExclusions
|
323
|
+
this.ppIdVl = ppId
|
324
|
+
this.cURLVl = ctURL
|
325
|
+
targetingAdRequest(
|
326
|
+
customTargeting,
|
327
|
+
categoryExclusions,
|
328
|
+
ppId,
|
329
|
+
ctURL,
|
330
|
+
brandSafetyArr
|
331
|
+
)
|
332
|
+
callbackContext.success()
|
333
|
+
} catch (e: Exception) {
|
334
|
+
callbackContext.error(e.toString())
|
335
|
+
}
|
321
336
|
}
|
322
337
|
}
|
323
338
|
return true
|
324
339
|
} else if (action == "setPersonalizationState") {
|
325
340
|
val options = args.getJSONObject(0)
|
326
|
-
mActivity
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
341
|
+
if(mActivity != null) {
|
342
|
+
mActivity!!.runOnUiThread {
|
343
|
+
val setPPT = options.optString("setPersonalizationState")
|
344
|
+
try {
|
345
|
+
setPersonalizationState(setPPT)
|
346
|
+
callbackContext.success()
|
347
|
+
} catch (e: Exception) {
|
348
|
+
callbackContext.error(e.toString())
|
349
|
+
}
|
333
350
|
}
|
334
351
|
}
|
335
352
|
return true
|
336
353
|
} else if (action == "setPPS") {
|
337
354
|
val options = args.getJSONObject(0)
|
338
|
-
mActivity
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
355
|
+
if(mActivity != null) {
|
356
|
+
mActivity!!.runOnUiThread {
|
357
|
+
val ppsEnabled = options.optBoolean("ppsEnabled")
|
358
|
+
val iabContent = options.optString("iabContent")
|
359
|
+
val ppsArrValue = options.optJSONArray("ppsArrValue")
|
360
|
+
try {
|
361
|
+
this.ppsEnabled = ppsEnabled
|
362
|
+
this.ppsVl = iabContent
|
363
|
+
setPublisherProvidedSignals(ppsArrValue)
|
364
|
+
callbackContext.success()
|
365
|
+
} catch (e: Exception) {
|
366
|
+
callbackContext.error(e.toString())
|
367
|
+
}
|
349
368
|
}
|
350
369
|
}
|
351
370
|
return true
|
352
371
|
} else if (action == "globalSettings") {
|
353
372
|
val options = args.getJSONObject(0)
|
354
|
-
mActivity
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
373
|
+
if(mActivity != null) {
|
374
|
+
mActivity!!.runOnUiThread {
|
375
|
+
val setAppMuted = options.optBoolean("setAppMuted")
|
376
|
+
val setAppVolume = options.optInt("setAppVolume").toFloat()
|
377
|
+
val pubIdEnabled = options.optBoolean("pubIdEnabled")
|
378
|
+
try {
|
379
|
+
globalSettings(setAppMuted, setAppVolume, pubIdEnabled)
|
380
|
+
} catch (e: Exception) {
|
381
|
+
callbackContext.error(e.toString())
|
382
|
+
}
|
363
383
|
}
|
364
384
|
}
|
365
385
|
return true
|
366
386
|
} else if (action == "loadAppOpenAd") {
|
367
387
|
val options = args.getJSONObject(0)
|
368
|
-
mActivity
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
388
|
+
if(mActivity != null) {
|
389
|
+
mActivity!!.runOnUiThread {
|
390
|
+
val adUnitId = options.optString("adUnitId")
|
391
|
+
val autoShow = options.optBoolean("autoShow")
|
392
|
+
try {
|
393
|
+
this.appOpenAutoShow = autoShow
|
394
|
+
AppOpenAd.load(
|
395
|
+
mActivity!!, adUnitId, buildAdRequest(),
|
396
|
+
object : AppOpenAdLoadCallback() {
|
397
|
+
@SuppressLint("DefaultLocale")
|
398
|
+
override fun onAdLoaded(ad: AppOpenAd) {
|
399
|
+
appOpenAd = ad
|
400
|
+
isAppOpenAdShow = true
|
401
|
+
|
402
|
+
if (appOpenAutoShow) {
|
403
|
+
openAutoShow()
|
404
|
+
}
|
405
|
+
|
406
|
+
cWebView!!.loadUrl(
|
407
|
+
"javascript:cordova.fireDocumentEvent('on.appOpenAd.loaded');"
|
408
|
+
)
|
384
409
|
|
385
|
-
|
410
|
+
appOpenAdLoadCallback()
|
386
411
|
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
412
|
+
appOpenAd!!.onPaidEventListener =
|
413
|
+
OnPaidEventListener { adValue: AdValue ->
|
414
|
+
val valueMicros = adValue.valueMicros
|
415
|
+
val currencyCode = adValue.currencyCode
|
416
|
+
val precision = adValue.precisionType
|
417
|
+
val appOpenAdAdUnitId = appOpenAd!!.adUnitId
|
393
418
|
|
419
|
+
val result = JSONObject()
|
420
|
+
try {
|
421
|
+
result.put("micros", valueMicros)
|
422
|
+
result.put("currency", currencyCode)
|
423
|
+
result.put("precision", precision)
|
424
|
+
result.put("adUnitId", appOpenAdAdUnitId)
|
425
|
+
|
426
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.revenue', ${result})")
|
427
|
+
|
428
|
+
} catch (e: JSONException) {
|
429
|
+
callbackContext.error(e.message)
|
430
|
+
}
|
431
|
+
}
|
432
|
+
|
433
|
+
if (isResponseInfo) {
|
394
434
|
val result = JSONObject()
|
435
|
+
val responseInfo = ad.responseInfo
|
395
436
|
try {
|
396
|
-
result.put("
|
397
|
-
result.put(
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
437
|
+
result.put("getResponseId", responseInfo.responseId)
|
438
|
+
result.put(
|
439
|
+
"getAdapterResponses",
|
440
|
+
responseInfo.adapterResponses
|
441
|
+
)
|
442
|
+
result.put(
|
443
|
+
"getResponseExtras",
|
444
|
+
responseInfo.responseExtras
|
445
|
+
)
|
446
|
+
result.put(
|
447
|
+
"getMediationAdapterClassName",
|
448
|
+
responseInfo.mediationAdapterClassName
|
449
|
+
)
|
450
|
+
result.put("getBundleExtra", mBundleExtra.toString())
|
451
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.responseInfo', ${result})")
|
403
452
|
} catch (e: JSONException) {
|
404
453
|
callbackContext.error(e.message)
|
405
454
|
}
|
406
455
|
}
|
407
456
|
|
408
|
-
if (isResponseInfo) {
|
409
|
-
val result = JSONObject()
|
410
|
-
val responseInfo = ad.responseInfo
|
411
|
-
try {
|
412
|
-
result.put("getResponseId", responseInfo.responseId)
|
413
|
-
result.put(
|
414
|
-
"getAdapterResponses",
|
415
|
-
responseInfo.adapterResponses
|
416
|
-
)
|
417
|
-
result.put("getResponseExtras", responseInfo.responseExtras)
|
418
|
-
result.put(
|
419
|
-
"getMediationAdapterClassName",
|
420
|
-
responseInfo.mediationAdapterClassName
|
421
|
-
)
|
422
|
-
result.put("getBundleExtra", mBundleExtra.toString())
|
423
|
-
callbackContext.success(result)
|
424
|
-
} catch (e: JSONException) {
|
425
|
-
callbackContext.error(e.message)
|
426
|
-
}
|
427
|
-
}
|
428
457
|
|
429
|
-
cWebView!!.loadUrl(
|
430
|
-
"javascript:cordova.fireDocumentEvent('on.appOpenAd.loaded');"
|
431
|
-
)
|
432
458
|
|
433
|
-
|
459
|
+
}
|
434
460
|
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
461
|
+
private fun openAutoShow() {
|
462
|
+
try {
|
463
|
+
if (mActivity != null && isAppOpenAdShow && appOpenAd != null) {
|
464
|
+
mActivity!!.runOnUiThread {
|
465
|
+
appOpenAd!!.show(
|
466
|
+
mActivity!!
|
467
|
+
)
|
468
|
+
}
|
469
|
+
}
|
470
|
+
} catch (e: Exception) {
|
471
|
+
PUBLIC_CALLBACKS!!.error(e.toString())
|
472
|
+
}
|
442
473
|
}
|
443
|
-
}
|
444
474
|
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
475
|
+
override fun onAdFailedToLoad(loadAdError: LoadAdError) {
|
476
|
+
isAppOpenAdShow = false
|
477
|
+
val errorData = JSONObject().apply {
|
478
|
+
put("responseInfo", loadAdError.responseInfo)
|
479
|
+
put("code", loadAdError.code)
|
480
|
+
put("message", loadAdError.message)
|
481
|
+
put("domain", loadAdError.domain)
|
482
|
+
put("cause", loadAdError.cause?.toString() ?: "null")
|
483
|
+
}
|
484
|
+
cWebView!!.loadUrl(
|
485
|
+
"javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.loaded, ${errorData}');"
|
486
|
+
)
|
487
|
+
}
|
488
|
+
})
|
489
|
+
} catch (e: Exception) {
|
490
|
+
callbackContext.error(e.toString())
|
491
|
+
}
|
455
492
|
}
|
456
493
|
}
|
457
494
|
return true
|
458
495
|
} else if (action == "showAppOpenAd") {
|
459
|
-
|
460
|
-
|
461
|
-
mActivity
|
462
|
-
|
463
|
-
|
464
|
-
|
496
|
+
|
497
|
+
try {
|
498
|
+
if (mActivity != null && isAppOpenAdShow && appOpenAd != null) {
|
499
|
+
mActivity!!.runOnUiThread { appOpenAd!!.show(mActivity!!) }
|
500
|
+
appOpenAdLoadCallback()
|
501
|
+
} else {
|
502
|
+
callbackContext.error("The App Open Ad wasn't ready yet")
|
503
|
+
}
|
504
|
+
} catch (e: Exception) {
|
505
|
+
PUBLIC_CALLBACKS!!.error(e.toString())
|
465
506
|
}
|
466
|
-
} catch (e: Exception) {
|
467
|
-
PUBLIC_CALLBACKS!!.error(e.toString())
|
468
|
-
}
|
469
507
|
|
470
508
|
return true
|
471
509
|
} else if (action == "loadInterstitialAd") {
|
472
510
|
val options = args.getJSONObject(0)
|
473
|
-
mActivity
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
511
|
+
if(mActivity != null) {
|
512
|
+
mActivity!!.runOnUiThread {
|
513
|
+
val adUnitId = options.optString("adUnitId")
|
514
|
+
val autoShow = options.optBoolean("autoShow")
|
515
|
+
try {
|
516
|
+
this.intAutoShow = autoShow
|
517
|
+
InterstitialAd.load(
|
518
|
+
mActivity!!, adUnitId, buildAdRequest(),
|
519
|
+
object : InterstitialAdLoadCallback() {
|
520
|
+
override fun onAdLoaded(interstitialAd: InterstitialAd) {
|
521
|
+
isInterstitialLoad = true
|
522
|
+
mInterstitialAd = interstitialAd
|
523
|
+
|
524
|
+
if (intAutoShow) {
|
525
|
+
isIntAutoShow
|
526
|
+
}
|
488
527
|
|
489
|
-
|
528
|
+
cWebView!!.loadUrl(
|
529
|
+
"javascript:cordova.fireDocumentEvent('on.interstitial.loaded');"
|
530
|
+
)
|
490
531
|
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
if (isResponseInfo) {
|
495
|
-
val result = JSONObject()
|
496
|
-
val responseInfo = mInterstitialAd!!.responseInfo
|
497
|
-
try {
|
498
|
-
result.put("getResponseId", responseInfo.responseId)
|
499
|
-
result.put(
|
500
|
-
"getAdapterResponses",
|
501
|
-
responseInfo.adapterResponses
|
502
|
-
)
|
503
|
-
result.put("getResponseExtras", responseInfo.responseExtras)
|
504
|
-
result.put(
|
505
|
-
"getMediationAdapterClassName",
|
506
|
-
responseInfo.mediationAdapterClassName
|
507
|
-
)
|
508
|
-
result.put("getBundleExtra", mBundleExtra.toString())
|
509
|
-
callbackContext.success(result)
|
510
|
-
} catch (e: JSONException) {
|
511
|
-
callbackContext.error(e.message)
|
512
|
-
}
|
513
|
-
}
|
514
|
-
mInterstitialAd!!.onPaidEventListener =
|
515
|
-
OnPaidEventListener { adValue: AdValue ->
|
516
|
-
val valueMicros = adValue.valueMicros
|
517
|
-
val currencyCode = adValue.currencyCode
|
518
|
-
val precision = adValue.precisionType
|
519
|
-
val interstitialAdUnitId = mInterstitialAd!!.adUnitId
|
532
|
+
interstitialAdLoadCallback()
|
533
|
+
|
534
|
+
if (isResponseInfo) {
|
520
535
|
val result = JSONObject()
|
536
|
+
val responseInfo = mInterstitialAd!!.responseInfo
|
521
537
|
try {
|
522
|
-
result.put("
|
523
|
-
result.put(
|
524
|
-
|
525
|
-
|
526
|
-
|
538
|
+
result.put("getResponseId", responseInfo.responseId)
|
539
|
+
result.put(
|
540
|
+
"getAdapterResponses",
|
541
|
+
responseInfo.adapterResponses
|
542
|
+
)
|
543
|
+
result.put("getResponseExtras", responseInfo.responseExtras)
|
544
|
+
result.put(
|
545
|
+
"getMediationAdapterClassName",
|
546
|
+
responseInfo.mediationAdapterClassName
|
547
|
+
)
|
548
|
+
result.put("getBundleExtra", mBundleExtra.toString())
|
549
|
+
cWebView!!.loadUrl(
|
550
|
+
"javascript:cordova.fireDocumentEvent('on.interstitialAd.responseInfo', ${result});"
|
551
|
+
)
|
552
|
+
|
527
553
|
} catch (e: JSONException) {
|
528
554
|
callbackContext.error(e.message)
|
529
555
|
}
|
530
|
-
cWebView!!.loadUrl(
|
531
|
-
"javascript:cordova.fireDocumentEvent('on.interstitial.revenue');"
|
532
|
-
)
|
533
556
|
}
|
534
|
-
|
557
|
+
mInterstitialAd!!.onPaidEventListener =
|
558
|
+
OnPaidEventListener { adValue: AdValue ->
|
559
|
+
val valueMicros = adValue.valueMicros
|
560
|
+
val currencyCode = adValue.currencyCode
|
561
|
+
val precision = adValue.precisionType
|
562
|
+
val interstitialAdUnitId = mInterstitialAd!!.adUnitId
|
563
|
+
val result = JSONObject()
|
564
|
+
try {
|
565
|
+
result.put("micros", valueMicros)
|
566
|
+
result.put("currency", currencyCode)
|
567
|
+
result.put("precision", precision)
|
568
|
+
result.put("adUnitId", interstitialAdUnitId)
|
569
|
+
cWebView!!.loadUrl(
|
570
|
+
"javascript:cordova.fireDocumentEvent('on.interstitial.revenue', ${result});"
|
571
|
+
)
|
535
572
|
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
573
|
+
} catch (e: JSONException) {
|
574
|
+
callbackContext.error(e.message)
|
575
|
+
}
|
576
|
+
|
577
|
+
}
|
541
578
|
}
|
542
579
|
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
580
|
+
private val isIntAutoShow: Unit
|
581
|
+
get() {
|
582
|
+
if (mActivity != null && isInterstitialLoad && mInterstitialAd != null) {
|
583
|
+
mActivity!!.runOnUiThread { mInterstitialAd!!.show(mActivity!!) }
|
584
|
+
}
|
585
|
+
}
|
586
|
+
|
587
|
+
override fun onAdFailedToLoad(loadAdError: LoadAdError) {
|
588
|
+
mInterstitialAd = null
|
589
|
+
isInterstitialLoad = false
|
590
|
+
val errorData = JSONObject().apply {
|
591
|
+
put("responseInfo", loadAdError.responseInfo)
|
592
|
+
put("code", loadAdError.code)
|
593
|
+
put("message", loadAdError.message)
|
594
|
+
put("domain", loadAdError.domain)
|
595
|
+
put("cause", loadAdError.cause?.toString() ?: "null")
|
596
|
+
}
|
597
|
+
cWebView!!.loadUrl(
|
598
|
+
"javascript:cordova.fireDocumentEvent('on.interstitial.failed.load', ${errorData});"
|
599
|
+
)
|
600
|
+
|
601
|
+
}
|
602
|
+
})
|
603
|
+
} catch (e: Exception) {
|
604
|
+
callbackContext.error(e.toString())
|
605
|
+
}
|
554
606
|
}
|
555
607
|
}
|
556
608
|
return true
|
557
609
|
} else if (action == "showInterstitialAd") {
|
558
|
-
|
559
|
-
mActivity
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
610
|
+
|
611
|
+
if (mActivity != null && isInterstitialLoad && mInterstitialAd != null) {
|
612
|
+
mActivity!!.runOnUiThread { mInterstitialAd!!.show(mActivity!!) }
|
613
|
+
interstitialAdLoadCallback()
|
614
|
+
} else {
|
615
|
+
callbackContext.error("The Interstitial ad wasn't ready yet")
|
616
|
+
}
|
564
617
|
return true
|
565
618
|
} else if (action == "loadRewardedAd") {
|
566
619
|
val options = args.getJSONObject(0)
|
567
|
-
mActivity
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
isRewardedLoad = true
|
587
|
-
isAdSkip = 0
|
588
|
-
if (rewardedAutoShow) {
|
589
|
-
isRewardedAutoShow
|
590
|
-
}
|
591
|
-
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.loaded');")
|
592
|
-
rewardedAdLoadCallback(callbackContext)
|
593
|
-
if (isResponseInfo) {
|
594
|
-
val result = JSONObject()
|
595
|
-
val responseInfo = ad.responseInfo
|
596
|
-
try {
|
597
|
-
result.put("getResponseId", responseInfo.responseId)
|
598
|
-
result.put(
|
599
|
-
"getAdapterResponses",
|
600
|
-
responseInfo.adapterResponses
|
601
|
-
)
|
602
|
-
result.put("getResponseExtras", responseInfo.responseExtras)
|
603
|
-
result.put(
|
604
|
-
"getMediationAdapterClassName",
|
605
|
-
responseInfo.mediationAdapterClassName
|
606
|
-
)
|
607
|
-
result.put("getBundleExtra", mBundleExtra.toString())
|
608
|
-
callbackContext.success(result)
|
609
|
-
} catch (e: JSONException) {
|
610
|
-
callbackContext.error(e.message)
|
620
|
+
if(mActivity != null) {
|
621
|
+
mActivity!!.runOnUiThread {
|
622
|
+
val adUnitId = options.optString("adUnitId")
|
623
|
+
val autoShow = options.optBoolean("autoShow")
|
624
|
+
try {
|
625
|
+
this.rewardedAutoShow = autoShow
|
626
|
+
RewardedAd.load(
|
627
|
+
mActivity!!, adUnitId, buildAdRequest(),
|
628
|
+
object : RewardedAdLoadCallback() {
|
629
|
+
override fun onAdFailedToLoad(loadAdError: LoadAdError) {
|
630
|
+
rewardedAd = null
|
631
|
+
isRewardedLoad = false
|
632
|
+
|
633
|
+
val errorData = JSONObject().apply {
|
634
|
+
put("responseInfo", loadAdError.responseInfo)
|
635
|
+
put("code", loadAdError.code)
|
636
|
+
put("message", loadAdError.message)
|
637
|
+
put("domain", loadAdError.domain)
|
638
|
+
put("cause", loadAdError.cause?.toString() ?: "null")
|
611
639
|
}
|
640
|
+
|
641
|
+
cWebView!!.loadUrl(
|
642
|
+
"javascript:cordova.fireDocumentEvent('on.rewarded.failed.load', ${errorData});"
|
643
|
+
)
|
644
|
+
|
612
645
|
}
|
613
646
|
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
val result = JSONObject()
|
621
|
-
try {
|
622
|
-
result.put("micros", valueMicros)
|
623
|
-
result.put("currency", currencyCode)
|
624
|
-
result.put("precision", precision)
|
625
|
-
result.put("adUnitId", rewardedAdAdUnitId)
|
626
|
-
callbackContext.success(result)
|
627
|
-
} catch (e: JSONException) {
|
628
|
-
callbackContext.error(e.message)
|
629
|
-
}
|
630
|
-
cWebView!!.loadUrl(
|
631
|
-
"javascript:cordova.fireDocumentEvent('on.rewarded.revenue');"
|
632
|
-
)
|
647
|
+
override fun onAdLoaded(ad: RewardedAd) {
|
648
|
+
rewardedAd = ad
|
649
|
+
isRewardedLoad = true
|
650
|
+
isAdSkip = 0
|
651
|
+
if (rewardedAutoShow) {
|
652
|
+
isRewardedAutoShow
|
633
653
|
}
|
634
|
-
}
|
635
654
|
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
655
|
+
|
656
|
+
rewardedAdLoadCallback()
|
657
|
+
|
658
|
+
cWebView!!.loadUrl(
|
659
|
+
"javascript:cordova.fireDocumentEvent('on.rewarded.loaded');"
|
660
|
+
)
|
661
|
+
|
662
|
+
rewardedAd!!.onPaidEventListener =
|
663
|
+
OnPaidEventListener { adValue: AdValue ->
|
664
|
+
val valueMicros = adValue.valueMicros
|
665
|
+
val currencyCode = adValue.currencyCode
|
666
|
+
val precision = adValue.precisionType
|
667
|
+
val rewardedAdAdUnitId = rewardedAd!!.adUnitId
|
644
668
|
val result = JSONObject()
|
645
669
|
try {
|
646
|
-
result.put("
|
647
|
-
result.put("
|
648
|
-
|
670
|
+
result.put("micros", valueMicros)
|
671
|
+
result.put("currency", currencyCode)
|
672
|
+
result.put("precision", precision)
|
673
|
+
result.put("adUnitId", rewardedAdAdUnitId)
|
674
|
+
cWebView!!.loadUrl(
|
675
|
+
"javascript:cordova.fireDocumentEvent('on.rewarded.revenue', ${result});"
|
676
|
+
)
|
649
677
|
} catch (e: JSONException) {
|
650
678
|
callbackContext.error(e.message)
|
651
679
|
}
|
652
|
-
|
653
|
-
|
680
|
+
|
681
|
+
}
|
682
|
+
|
683
|
+
|
684
|
+
|
685
|
+
if (isResponseInfo) {
|
686
|
+
val result = JSONObject()
|
687
|
+
val responseInfo = ad.responseInfo
|
688
|
+
try {
|
689
|
+
result.put("getResponseId", responseInfo.responseId)
|
690
|
+
result.put(
|
691
|
+
"getAdapterResponses",
|
692
|
+
responseInfo.adapterResponses
|
693
|
+
)
|
694
|
+
result.put(
|
695
|
+
"getResponseExtras",
|
696
|
+
responseInfo.responseExtras
|
654
697
|
)
|
698
|
+
result.put(
|
699
|
+
"getMediationAdapterClassName",
|
700
|
+
responseInfo.mediationAdapterClassName
|
701
|
+
)
|
702
|
+
result.put("getBundleExtra", mBundleExtra.toString())
|
703
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAd.responseInfo', ${result})")
|
704
|
+
} catch (e: JSONException) {
|
705
|
+
callbackContext.error(e.message)
|
655
706
|
}
|
656
707
|
}
|
708
|
+
|
709
|
+
|
657
710
|
}
|
658
|
-
|
659
|
-
|
660
|
-
|
711
|
+
|
712
|
+
private val isRewardedAutoShow: Unit
|
713
|
+
get() {
|
714
|
+
if (mActivity != null){
|
715
|
+
mActivity!!.runOnUiThread {
|
716
|
+
if (isRewardedLoad && rewardedAd != null) {
|
717
|
+
isAdSkip = 1
|
718
|
+
rewardedAd!!.show(mActivity!!) { rewardItem: RewardItem ->
|
719
|
+
isAdSkip = 2
|
720
|
+
val rewardAmount = rewardItem.amount
|
721
|
+
val rewardType = rewardItem.type
|
722
|
+
val result = JSONObject()
|
723
|
+
try {
|
724
|
+
result.put("rewardType", rewardType)
|
725
|
+
result.put("rewardAmount", rewardAmount)
|
726
|
+
cWebView!!.loadUrl(
|
727
|
+
"javascript:cordova.fireDocumentEvent('on.reward.userEarnedReward', ${result});"
|
728
|
+
)
|
729
|
+
} catch (e: JSONException) {
|
730
|
+
callbackContext.error(e.message)
|
731
|
+
}
|
732
|
+
|
733
|
+
}
|
734
|
+
}
|
735
|
+
}
|
736
|
+
}
|
737
|
+
}
|
738
|
+
})
|
739
|
+
} catch (e: Exception) {
|
740
|
+
callbackContext.error(e.toString())
|
741
|
+
}
|
661
742
|
}
|
662
743
|
}
|
663
744
|
return true
|
664
745
|
} else if (action == "showRewardedAd") {
|
665
|
-
mActivity
|
666
|
-
|
746
|
+
if(mActivity != null && isRewardedLoad && rewardedAd != null) {
|
747
|
+
mActivity!!.runOnUiThread {
|
667
748
|
isAdSkip = 1
|
668
749
|
rewardedAd!!.show(mActivity!!) { rewardItem: RewardItem ->
|
669
750
|
isAdSkip = 2
|
@@ -671,354 +752,394 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
671
752
|
val rewardType = rewardItem.type
|
672
753
|
val result = JSONObject()
|
673
754
|
try {
|
674
|
-
result.put("rewardAmount", rewardAmount)
|
675
755
|
result.put("rewardType", rewardType)
|
676
|
-
|
756
|
+
result.put("rewardAmount", rewardAmount)
|
757
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.reward.userEarnedReward', ${result});")
|
677
758
|
} catch (e: JSONException) {
|
678
759
|
callbackContext.error(e.message)
|
679
760
|
}
|
680
|
-
|
761
|
+
|
681
762
|
}
|
682
|
-
rewardedAdLoadCallback(
|
683
|
-
|
684
|
-
callbackContext.error("The rewarded ad wasn't ready yet")
|
763
|
+
rewardedAdLoadCallback()
|
764
|
+
|
685
765
|
}
|
766
|
+
|
767
|
+
} else {
|
768
|
+
callbackContext.error("The rewarded ad wasn't ready yet")
|
686
769
|
}
|
687
770
|
return true
|
688
771
|
} else if (action == "loadRewardedInterstitialAd") {
|
689
772
|
val options = args.getJSONObject(0)
|
690
|
-
mActivity
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
773
|
+
if(mActivity != null) {
|
774
|
+
mActivity!!.runOnUiThread {
|
775
|
+
val adUnitId = options.optString("adUnitId")
|
776
|
+
val autoShow = options.optBoolean("autoShow")
|
777
|
+
try {
|
778
|
+
this.rIntAutoShow = autoShow
|
779
|
+
RewardedInterstitialAd.load(
|
780
|
+
mActivity!!, adUnitId, buildAdRequest(),
|
781
|
+
object : RewardedInterstitialAdLoadCallback() {
|
782
|
+
override fun onAdLoaded(ad: RewardedInterstitialAd) {
|
783
|
+
rewardedInterstitialAd = ad
|
784
|
+
isRewardedInterstitialLoad = true
|
785
|
+
isAdSkip = 0
|
786
|
+
|
787
|
+
cWebView!!.loadUrl(
|
788
|
+
"javascript:cordova.fireDocumentEvent('on.rewardedInt.loaded');"
|
789
|
+
)
|
790
|
+
|
791
|
+
if (rIntAutoShow) {
|
792
|
+
isRIntAutoShow
|
793
|
+
}
|
709
794
|
|
795
|
+
rewardedInterstitialAdLoadCallback()
|
796
|
+
|
797
|
+
rewardedInterstitialAd!!.onPaidEventListener =
|
798
|
+
OnPaidEventListener { adValue: AdValue ->
|
799
|
+
val valueMicros = adValue.valueMicros
|
800
|
+
val currencyCode = adValue.currencyCode
|
801
|
+
val precision = adValue.precisionType
|
802
|
+
val rewardedIntAdUnitId =
|
803
|
+
rewardedInterstitialAd!!.adUnitId
|
804
|
+
val result = JSONObject()
|
805
|
+
try {
|
806
|
+
result.put("micros", valueMicros)
|
807
|
+
result.put("currency", currencyCode)
|
808
|
+
result.put("precision", precision)
|
809
|
+
result.put("adUnitId", rewardedIntAdUnitId)
|
810
|
+
cWebView!!.loadUrl(
|
811
|
+
"javascript:cordova.fireDocumentEvent('on.rewardedInt.revenue', ${result});"
|
812
|
+
)
|
813
|
+
} catch (e: JSONException) {
|
814
|
+
callbackContext.error(e.message)
|
815
|
+
}
|
816
|
+
|
817
|
+
}
|
710
818
|
|
711
|
-
cWebView!!.loadUrl(
|
712
|
-
"javascript:cordova.fireDocumentEvent('on.rewardedInt.loaded');"
|
713
|
-
)
|
714
|
-
}
|
715
819
|
|
716
|
-
|
717
|
-
rewardedInterstitialAd!!.onPaidEventListener =
|
718
|
-
OnPaidEventListener { adValue: AdValue ->
|
719
|
-
val valueMicros = adValue.valueMicros
|
720
|
-
val currencyCode = adValue.currencyCode
|
721
|
-
val precision = adValue.precisionType
|
722
|
-
val rewardedIntAdUnitId = rewardedInterstitialAd!!.adUnitId
|
820
|
+
if (isResponseInfo) {
|
723
821
|
val result = JSONObject()
|
822
|
+
val responseInfo = rewardedInterstitialAd!!.responseInfo
|
724
823
|
try {
|
725
|
-
result.put("
|
726
|
-
result.put(
|
727
|
-
|
728
|
-
|
729
|
-
|
824
|
+
result.put("getResponseId", responseInfo.responseId)
|
825
|
+
result.put(
|
826
|
+
"getAdapterResponses",
|
827
|
+
responseInfo.adapterResponses
|
828
|
+
)
|
829
|
+
result.put(
|
830
|
+
"getResponseExtras",
|
831
|
+
responseInfo.responseExtras
|
832
|
+
)
|
833
|
+
result.put(
|
834
|
+
"getMediationAdapterClassName",
|
835
|
+
responseInfo.mediationAdapterClassName
|
836
|
+
)
|
837
|
+
result.put("getBundleExtra", mBundleExtra.toString())
|
838
|
+
cWebView!!.loadUrl(
|
839
|
+
"javascript:cordova.fireDocumentEvent('on.rewardedIntAd.responseInfo', ${result});"
|
840
|
+
)
|
730
841
|
} catch (e: JSONException) {
|
731
842
|
callbackContext.error(e.message)
|
732
843
|
}
|
733
|
-
cWebView!!.loadUrl(
|
734
|
-
"javascript:cordova.fireDocumentEvent('on.rewardedInt.revenue');"
|
735
|
-
)
|
736
844
|
}
|
737
|
-
}
|
738
845
|
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
val responseInfo = rewardedInterstitialAd!!.responseInfo
|
743
|
-
try {
|
744
|
-
result.put("getResponseId", responseInfo.responseId)
|
745
|
-
result.put(
|
746
|
-
"getAdapterResponses",
|
747
|
-
responseInfo.adapterResponses
|
748
|
-
)
|
749
|
-
result.put("getResponseExtras", responseInfo.responseExtras)
|
750
|
-
result.put(
|
751
|
-
"getMediationAdapterClassName",
|
752
|
-
responseInfo.mediationAdapterClassName
|
753
|
-
)
|
754
|
-
result.put("getBundleExtra", mBundleExtra.toString())
|
755
|
-
callbackContext.success(result)
|
756
|
-
} catch (e: JSONException) {
|
757
|
-
callbackContext.error(e.message)
|
758
|
-
}
|
846
|
+
|
847
|
+
|
848
|
+
|
759
849
|
}
|
760
|
-
}
|
761
850
|
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
851
|
+
|
852
|
+
|
853
|
+
private val isRIntAutoShow: Unit
|
854
|
+
get() {
|
855
|
+
if (mActivity !== null) {
|
856
|
+
mActivity!!.runOnUiThread {
|
857
|
+
if (isRewardedInterstitialLoad && rewardedInterstitialAd != null) {
|
858
|
+
isAdSkip = 1
|
859
|
+
rewardedInterstitialAd!!.show(mActivity!!) { rewardItem: RewardItem ->
|
860
|
+
isAdSkip = 2
|
861
|
+
val rewardAmount = rewardItem.amount
|
862
|
+
val rewardType = rewardItem.type
|
863
|
+
val result = JSONObject()
|
864
|
+
try {
|
865
|
+
result.put("rewardType", rewardType)
|
866
|
+
result.put("rewardAmount", rewardAmount)
|
867
|
+
cWebView!!.loadUrl(
|
868
|
+
"javascript:cordova.fireDocumentEvent('on.rewardedInt.userEarnedReward', ${result});"
|
869
|
+
)
|
870
|
+
} catch (e: JSONException) {
|
871
|
+
callbackContext.error(e.message)
|
872
|
+
}
|
873
|
+
|
874
|
+
}
|
875
|
+
}
|
777
876
|
}
|
778
|
-
cWebView!!.loadUrl(
|
779
|
-
"javascript:cordova.fireDocumentEvent('on.rewardedInt.userEarnedReward');"
|
780
|
-
)
|
781
877
|
}
|
782
878
|
}
|
783
|
-
}
|
784
879
|
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
880
|
+
override fun onAdFailedToLoad(loadAdError: LoadAdError) {
|
881
|
+
rewardedInterstitialAd = null
|
882
|
+
isRewardedInterstitialLoad = false
|
883
|
+
val errorData = JSONObject().apply {
|
884
|
+
put("responseInfo", loadAdError.responseInfo)
|
885
|
+
put("code", loadAdError.code)
|
886
|
+
put("message", loadAdError.message)
|
887
|
+
put("domain", loadAdError.domain)
|
888
|
+
put("cause", loadAdError.cause?.toString() ?: "null")
|
889
|
+
}
|
890
|
+
cWebView!!.loadUrl(
|
891
|
+
"javascript:cordova.fireDocumentEvent('on.rewardedInt.failed.load', ${errorData});"
|
892
|
+
)
|
893
|
+
|
894
|
+
}
|
895
|
+
})
|
896
|
+
} catch (e: Exception) {
|
897
|
+
callbackContext.error(e.toString())
|
898
|
+
}
|
796
899
|
}
|
797
900
|
}
|
798
901
|
return true
|
799
902
|
} else if (action == "showRewardedInterstitialAd") {
|
800
|
-
mActivity
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
903
|
+
if(mActivity != null) {
|
904
|
+
mActivity!!.runOnUiThread {
|
905
|
+
if (isRewardedInterstitialLoad && rewardedInterstitialAd != null) {
|
906
|
+
isAdSkip = 1
|
907
|
+
rewardedInterstitialAd!!.show(mActivity!!) { rewardItem: RewardItem ->
|
908
|
+
isAdSkip = 2
|
909
|
+
val rewardAmount = rewardItem.amount
|
910
|
+
val rewardType = rewardItem.type
|
911
|
+
val result = JSONObject()
|
912
|
+
try {
|
913
|
+
result.put("rewardType", rewardType)
|
914
|
+
result.put("rewardAmount", rewardAmount)
|
915
|
+
cWebView!!.loadUrl(
|
916
|
+
"javascript:cordova.fireDocumentEvent('on.rewardedInt.userEarnedReward', ${result});"
|
917
|
+
)
|
918
|
+
} catch (e: JSONException) {
|
919
|
+
callbackContext.error(e.message)
|
920
|
+
}
|
921
|
+
|
814
922
|
}
|
815
|
-
|
816
|
-
|
817
|
-
)
|
923
|
+
rewardedInterstitialAdLoadCallback()
|
924
|
+
} else {
|
925
|
+
callbackContext.error("The rewarded ad wasn't ready yet")
|
818
926
|
}
|
819
|
-
|
820
|
-
rewardedInterstitialAdLoadCallback(callbackContext)
|
821
|
-
} else {
|
822
|
-
callbackContext.error("The rewarded ad wasn't ready yet")
|
823
927
|
}
|
824
928
|
}
|
825
929
|
return true
|
826
930
|
} else if (action == "showPrivacyOptionsForm") {
|
827
|
-
mActivity
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
.
|
835
|
-
|
931
|
+
if(mActivity != null) {
|
932
|
+
mActivity!!.runOnUiThread {
|
933
|
+
try {
|
934
|
+
val params: ConsentRequestParameters
|
935
|
+
if (this.setDebugGeography) {
|
936
|
+
val debugSettings = deviceId?.let {
|
937
|
+
mActivity?.let { it1 ->
|
938
|
+
ConsentDebugSettings.Builder(it1)
|
939
|
+
.setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA)
|
940
|
+
.addTestDeviceHashedId(it).build()
|
941
|
+
}
|
836
942
|
}
|
943
|
+
params = ConsentRequestParameters.Builder()
|
944
|
+
.setConsentDebugSettings(debugSettings).build()
|
945
|
+
} else {
|
946
|
+
params = ConsentRequestParameters.Builder()
|
947
|
+
.setTagForUnderAgeOfConsent(this.isSetTagForUnderAgeOfConsent)
|
948
|
+
.build()
|
837
949
|
}
|
838
|
-
|
839
|
-
.
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
it1
|
857
|
-
) { loadAndShowError: FormError? ->
|
858
|
-
if (loadAndShowError != null) {
|
859
|
-
cordova.activity.runOnUiThread {
|
860
|
-
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.show', { message: '" + loadAndShowError.message + "' });")
|
950
|
+
consentInformation = mContext?.let {
|
951
|
+
UserMessagingPlatform.getConsentInformation(
|
952
|
+
it
|
953
|
+
)
|
954
|
+
}
|
955
|
+
mActivity?.let {
|
956
|
+
consentInformation?.requestConsentInfoUpdate(
|
957
|
+
it,
|
958
|
+
params,
|
959
|
+
{
|
960
|
+
mActivity?.let { it1 ->
|
961
|
+
UserMessagingPlatform.loadAndShowConsentFormIfRequired(
|
962
|
+
it1
|
963
|
+
) { loadAndShowError: FormError? ->
|
964
|
+
if (loadAndShowError != null) {
|
965
|
+
mActivity!!.runOnUiThread {
|
966
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.show', { message: '" + loadAndShowError.message + "' });")
|
967
|
+
}
|
861
968
|
}
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
969
|
+
if (isPrivacyOptionsRequired == ConsentInformation.PrivacyOptionsRequirementStatus.REQUIRED) {
|
970
|
+
mActivity?.let { it2 ->
|
971
|
+
UserMessagingPlatform.showPrivacyOptionsForm(
|
972
|
+
it2
|
973
|
+
) { formError: FormError? ->
|
974
|
+
if (formError != null) {
|
975
|
+
mActivity!!.runOnUiThread {
|
976
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.show.options', { message: '" + formError.message + "' });")
|
977
|
+
}
|
871
978
|
}
|
872
979
|
}
|
873
980
|
}
|
874
981
|
}
|
875
982
|
}
|
876
983
|
}
|
877
|
-
}
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
984
|
+
},
|
985
|
+
{ requestConsentError: FormError ->
|
986
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.info.update.failed', { message: '" + requestConsentError.message + "' });")
|
987
|
+
})
|
988
|
+
}
|
989
|
+
} catch (e: Exception) {
|
990
|
+
callbackContext.error(e.toString())
|
882
991
|
}
|
883
|
-
} catch (e: Exception) {
|
884
|
-
callbackContext.error(e.toString())
|
885
992
|
}
|
886
993
|
}
|
887
994
|
return true
|
888
995
|
} else if (action == "consentReset") {
|
889
|
-
mActivity
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
996
|
+
if(mActivity != null) {
|
997
|
+
mActivity!!.runOnUiThread {
|
998
|
+
try {
|
999
|
+
consentInformation!!.reset()
|
1000
|
+
} catch (e: Exception) {
|
1001
|
+
callbackContext.error(e.toString())
|
1002
|
+
}
|
894
1003
|
}
|
895
1004
|
}
|
896
1005
|
return true
|
897
1006
|
} else if (action == "getIabTfc") {
|
898
|
-
mActivity
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
1007
|
+
if(mActivity != null) {
|
1008
|
+
mActivity!!.runOnUiThread {
|
1009
|
+
val gdprApplies = mPreferences!!.getInt("IABTCF_gdprApplies", 0)
|
1010
|
+
val purposeConsents = mPreferences!!.getString("IABTCF_PurposeConsents", "")
|
1011
|
+
val vendorConsents = mPreferences!!.getString("IABTCF_VendorConsents", "")
|
1012
|
+
val consentString = mPreferences!!.getString("IABTCF_TCString", "")
|
1013
|
+
val userInfoJson = JSONObject()
|
1014
|
+
try {
|
1015
|
+
userInfoJson.put("IABTCF_gdprApplies", gdprApplies)
|
1016
|
+
userInfoJson.put("IABTCF_PurposeConsents", purposeConsents)
|
1017
|
+
userInfoJson.put("IABTCF_VendorConsents", vendorConsents)
|
1018
|
+
userInfoJson.put("IABTCF_TCString", consentString)
|
1019
|
+
val editor = mPreferences!!.edit()
|
1020
|
+
editor.putString("IABTCF_TCString", consentString)
|
1021
|
+
editor.putLong(LAST_ACCESS_SUFFIX, System.currentTimeMillis())
|
1022
|
+
editor.apply()
|
1023
|
+
val key = "IABTCF_TCString"
|
1024
|
+
getString(key)
|
1025
|
+
callbackContext.success(userInfoJson)
|
1026
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.getIabTfc');")
|
1027
|
+
} catch (e: Exception) {
|
1028
|
+
callbackContext.error(e.toString())
|
1029
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.getIabTfc.error');")
|
1030
|
+
}
|
920
1031
|
}
|
921
1032
|
}
|
922
1033
|
return true
|
923
1034
|
} else if (action == "loadBannerAd") {
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
1035
|
+
if(mActivity != null) {
|
1036
|
+
val options = args.getJSONObject(0)
|
1037
|
+
mActivity!!.runOnUiThread {
|
1038
|
+
val adUnitId = options.optString("adUnitId")
|
1039
|
+
val position = options.optString("position")
|
1040
|
+
val collapsible = options.optString("collapsible")
|
1041
|
+
val size = options.optString("size")
|
1042
|
+
val autoResize = options.optBoolean("autoResize")
|
1043
|
+
val autoShow = options.optBoolean("autoShow")
|
1044
|
+
this.bannerAdUnitId = adUnitId
|
1045
|
+
this.isPosition = position
|
1046
|
+
this.isSize = size
|
1047
|
+
this.bannerAutoShow = autoShow
|
1048
|
+
this.isAutoResize = autoResize
|
1049
|
+
this.collapsiblePos = collapsible
|
1050
|
+
|
1051
|
+
isCollapsible = collapsible.isNotEmpty()
|
1052
|
+
try {
|
1053
|
+
loadBannerAd(adUnitId, position, size)
|
1054
|
+
} catch (e: Exception) {
|
1055
|
+
callbackContext.error(e.toString())
|
1056
|
+
}
|
944
1057
|
}
|
945
1058
|
}
|
946
1059
|
return true
|
947
1060
|
} else if (action == "showBannerAd") {
|
948
|
-
mActivity
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
1061
|
+
if(mActivity != null) {
|
1062
|
+
mActivity!!.runOnUiThread {
|
1063
|
+
if (isBannerPause == 0) {
|
1064
|
+
isShowBannerAds
|
1065
|
+
} else if (isBannerPause == 1) {
|
1066
|
+
try {
|
1067
|
+
bannerView!!.visibility = View.VISIBLE
|
1068
|
+
bannerView!!.resume()
|
1069
|
+
} catch (e: Exception) {
|
1070
|
+
callbackContext.error(e.toString())
|
1071
|
+
}
|
957
1072
|
}
|
958
1073
|
}
|
959
1074
|
}
|
960
1075
|
return true
|
961
1076
|
} else if (action == "styleBannerAd") {
|
962
1077
|
val options = args.getJSONObject(0)
|
963
|
-
mActivity
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
1078
|
+
if(mActivity != null) {
|
1079
|
+
mActivity!!.runOnUiThread {
|
1080
|
+
val paddingPx = options.optInt("padding")
|
1081
|
+
val marginsPx = options.optInt("margins")
|
1082
|
+
// final boolean autoResize = options.optBoolean("autoResize");
|
1083
|
+
try {
|
1084
|
+
this.paddingInPx = paddingPx
|
1085
|
+
this.marginsInPx = marginsPx
|
1086
|
+
// this.isAutoResize = autoResize;
|
1087
|
+
} catch (e: Exception) {
|
1088
|
+
callbackContext.error(e.toString())
|
1089
|
+
}
|
973
1090
|
}
|
974
1091
|
}
|
975
1092
|
return true
|
976
1093
|
} else if (action == "collapsibleBannerAd") {
|
977
1094
|
val options = args.getJSONObject(0)
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
1095
|
+
if(mActivity != null) {
|
1096
|
+
mActivity!!.runOnUiThread {
|
1097
|
+
val enableCollapsible = options.optBoolean("enabledBannerCollapsible")
|
1098
|
+
val collapsible = options.optString("collapsiblePosition")
|
1099
|
+
try {
|
1100
|
+
this.isCollapsible = enableCollapsible
|
1101
|
+
this.collapsiblePos = collapsible
|
1102
|
+
} catch (e: Exception) {
|
1103
|
+
callbackContext.error(e.toString())
|
1104
|
+
}
|
987
1105
|
}
|
988
1106
|
}
|
989
1107
|
return true
|
990
1108
|
} else if (action == "hideBannerAd") {
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1109
|
+
if(mActivity != null) {
|
1110
|
+
mActivity!!.runOnUiThread {
|
1111
|
+
if (isBannerShow) {
|
1112
|
+
try {
|
1113
|
+
bannerView!!.visibility = View.GONE
|
1114
|
+
bannerView!!.pause()
|
1115
|
+
isBannerLoad = false
|
1116
|
+
isBannerPause = 1
|
1117
|
+
} catch (e: Exception) {
|
1118
|
+
callbackContext.error(e.toString())
|
1119
|
+
}
|
1000
1120
|
}
|
1001
1121
|
}
|
1002
1122
|
}
|
1003
1123
|
return true
|
1004
1124
|
} else if (action == "removeBannerAd") {
|
1005
|
-
mActivity
|
1006
|
-
|
1007
|
-
|
1008
|
-
bannerViewLayout
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1125
|
+
if(mActivity != null) {
|
1126
|
+
mActivity!!.runOnUiThread {
|
1127
|
+
try {
|
1128
|
+
if (bannerViewLayout != null && bannerView != null) {
|
1129
|
+
bannerViewLayout!!.removeView(bannerView)
|
1130
|
+
bannerView!!.destroy()
|
1131
|
+
bannerView = null
|
1132
|
+
bannerViewLayout = null
|
1133
|
+
isBannerLoad = false
|
1134
|
+
isBannerShow = false
|
1135
|
+
isBannerPause = 2
|
1136
|
+
lock = true
|
1137
|
+
}
|
1138
|
+
} catch (e: Exception) {
|
1139
|
+
PUBLIC_CALLBACKS!!.error("Error removing banner: " + e.message)
|
1016
1140
|
}
|
1017
|
-
} catch (e: Exception) {
|
1018
|
-
PUBLIC_CALLBACKS!!.error("Error removing banner: " + e.message)
|
1019
1141
|
}
|
1020
1142
|
}
|
1021
|
-
|
1022
1143
|
return true
|
1023
1144
|
}
|
1024
1145
|
return false
|
@@ -1026,26 +1147,28 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1026
1147
|
|
1027
1148
|
|
1028
1149
|
private fun handleConsentForm() {
|
1029
|
-
if
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1150
|
+
if(mActivity != null) {
|
1151
|
+
if (consentInformation!!.isConsentFormAvailable) {
|
1152
|
+
mContext?.let {
|
1153
|
+
UserMessagingPlatform.loadConsentForm(it,
|
1154
|
+
{ consentForm: ConsentForm ->
|
1155
|
+
mActivity?.let { it1 ->
|
1156
|
+
consentForm.show(
|
1157
|
+
it1
|
1158
|
+
) { formError: FormError? ->
|
1159
|
+
if (formError != null) {
|
1160
|
+
mActivity!!.runOnUiThread {
|
1161
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.show', { message: '" + formError.message + "' });")
|
1162
|
+
}
|
1040
1163
|
}
|
1041
1164
|
}
|
1042
1165
|
}
|
1166
|
+
},
|
1167
|
+
{ formError: FormError ->
|
1168
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.load.from', { message: '" + formError.message + "' });")
|
1043
1169
|
}
|
1044
|
-
|
1045
|
-
|
1046
|
-
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.load.from', { message: '" + formError.message + "' });")
|
1047
|
-
}
|
1048
|
-
)
|
1170
|
+
)
|
1171
|
+
}
|
1049
1172
|
}
|
1050
1173
|
}
|
1051
1174
|
}
|
@@ -1170,12 +1293,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1170
1293
|
isBannerLoad = true
|
1171
1294
|
} else {
|
1172
1295
|
val errorMessage = "Error showing banner: bannerView or bannerViewLayout is null."
|
1173
|
-
|
1296
|
+
// Log.e("isBannerAutoShow", errorMessage)
|
1174
1297
|
PUBLIC_CALLBACKS!!.error(errorMessage)
|
1175
1298
|
}
|
1176
1299
|
} catch (e: Exception) {
|
1177
1300
|
val errorMessage = "Error showing banner: " + e.message
|
1178
|
-
|
1301
|
+
// Log.e("isBannerAutoShow", errorMessage, e)
|
1179
1302
|
PUBLIC_CALLBACKS!!.error(errorMessage)
|
1180
1303
|
}
|
1181
1304
|
}
|
@@ -1209,8 +1332,15 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1209
1332
|
}
|
1210
1333
|
|
1211
1334
|
override fun onAdFailedToLoad(adError: LoadAdError) {
|
1212
|
-
|
1213
|
-
|
1335
|
+
|
1336
|
+
val errorData = JSONObject().apply {
|
1337
|
+
put("responseInfo", adError.responseInfo)
|
1338
|
+
put("code", adError.code)
|
1339
|
+
put("message", adError.message)
|
1340
|
+
put("domain", adError.domain)
|
1341
|
+
put("cause", adError.cause?.toString() ?: "null")
|
1342
|
+
}
|
1343
|
+
|
1214
1344
|
if (bannerViewLayout != null && bannerView != null) {
|
1215
1345
|
bannerViewLayout!!.removeView(bannerView)
|
1216
1346
|
bannerView!!.destroy()
|
@@ -1221,13 +1351,9 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1221
1351
|
isBannerPause = 2
|
1222
1352
|
lock = true
|
1223
1353
|
}
|
1224
|
-
} catch (e: Exception) {
|
1225
|
-
PUBLIC_CALLBACKS!!.error("Error removing banner: " + e.message)
|
1226
|
-
}
|
1227
|
-
}
|
1228
1354
|
|
1229
|
-
|
1230
|
-
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.failed.load');")
|
1355
|
+
|
1356
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.failed.load', ${errorData});")
|
1231
1357
|
}
|
1232
1358
|
|
1233
1359
|
override fun onAdImpression() {
|
@@ -1245,7 +1371,6 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1245
1371
|
}
|
1246
1372
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.load');")
|
1247
1373
|
|
1248
|
-
|
1249
1374
|
val eventData = String.format(
|
1250
1375
|
"{\"collapsible\": \"%s\"}",
|
1251
1376
|
if (bannerView!!.isCollapsible) "collapsible" else "not collapsible"
|
@@ -1253,7 +1378,6 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1253
1378
|
|
1254
1379
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.is.collapsible', $eventData)")
|
1255
1380
|
|
1256
|
-
|
1257
1381
|
bannerView!!.onPaidEventListener = bannerPaidAdListener
|
1258
1382
|
|
1259
1383
|
if (isResponseInfo) {
|
@@ -1268,14 +1392,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1268
1392
|
"getMediationAdapterClassName",
|
1269
1393
|
responseInfo.mediationAdapterClassName
|
1270
1394
|
)
|
1271
|
-
|
1272
1395
|
if (mBundleExtra != null) {
|
1273
1396
|
result.put("getBundleExtra", mBundleExtra.toString())
|
1274
1397
|
} else {
|
1275
1398
|
result.put("getBundleExtra", JSONObject.NULL)
|
1276
1399
|
}
|
1277
|
-
|
1278
|
-
PUBLIC_CALLBACKS!!.success(result)
|
1400
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAd.responseInfo', ${result});")
|
1279
1401
|
} catch (e: JSONException) {
|
1280
1402
|
PUBLIC_CALLBACKS!!.error(e.toString())
|
1281
1403
|
}
|
@@ -1303,8 +1425,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1303
1425
|
result.put("adUnitId", adUnitId)
|
1304
1426
|
isBannerLoad = false
|
1305
1427
|
isBannerShow = true
|
1306
|
-
|
1307
|
-
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.revenue');")
|
1428
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.revenue', ${result});")
|
1308
1429
|
} catch (e: JSONException) {
|
1309
1430
|
PUBLIC_CALLBACKS!!.error(e.message)
|
1310
1431
|
}
|
@@ -1322,7 +1443,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1322
1443
|
|
1323
1444
|
"full_width_adaptive" -> bannerView!!.setAdSize(
|
1324
1445
|
AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(
|
1325
|
-
mContext!!,
|
1446
|
+
mContext!!, adWidth
|
1326
1447
|
)
|
1327
1448
|
)
|
1328
1449
|
|
@@ -1393,7 +1514,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1393
1514
|
|
1394
1515
|
|
1395
1516
|
|
1396
|
-
|
1517
|
+
private fun setUsingAdManagerRequest(isUsingAdManagerRequest: Boolean) {
|
1397
1518
|
this.isUsingAdManagerRequest = isUsingAdManagerRequest
|
1398
1519
|
}
|
1399
1520
|
|
@@ -1597,7 +1718,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1597
1718
|
}
|
1598
1719
|
|
1599
1720
|
|
1600
|
-
|
1721
|
+
private val deviceId: String?
|
1601
1722
|
get() {
|
1602
1723
|
var algorithm = "SHA-256"
|
1603
1724
|
try {
|
@@ -1667,7 +1788,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1667
1788
|
|
1668
1789
|
|
1669
1790
|
|
1670
|
-
private fun appOpenAdLoadCallback(
|
1791
|
+
private fun appOpenAdLoadCallback() {
|
1671
1792
|
appOpenAd!!.fullScreenContentCallback = object : FullScreenContentCallback() {
|
1672
1793
|
override fun onAdDismissedFullScreenContent() {
|
1673
1794
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.dismissed');")
|
@@ -1676,9 +1797,15 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1676
1797
|
}
|
1677
1798
|
|
1678
1799
|
override fun onAdFailedToShowFullScreenContent(adError: AdError) {
|
1679
|
-
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.show');")
|
1680
|
-
callbackContext.error(adError.toString())
|
1681
1800
|
appOpenAd = null
|
1801
|
+
isAppOpenAdShow = false
|
1802
|
+
val errorData = JSONObject().apply {
|
1803
|
+
put("code", adError.code)
|
1804
|
+
put("message", adError.message)
|
1805
|
+
put("domain", adError.domain)
|
1806
|
+
put("cause", adError.cause?.toString() ?: "null")
|
1807
|
+
}
|
1808
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.show', ${errorData});")
|
1682
1809
|
}
|
1683
1810
|
|
1684
1811
|
override fun onAdShowedFullScreenContent() {
|
@@ -1688,7 +1815,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1688
1815
|
}
|
1689
1816
|
|
1690
1817
|
|
1691
|
-
private fun interstitialAdLoadCallback(
|
1818
|
+
private fun interstitialAdLoadCallback() {
|
1692
1819
|
mInterstitialAd!!.fullScreenContentCallback = object : FullScreenContentCallback() {
|
1693
1820
|
override fun onAdClicked() {
|
1694
1821
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.click');")
|
@@ -1705,8 +1832,13 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1705
1832
|
override fun onAdFailedToShowFullScreenContent(adError: AdError) {
|
1706
1833
|
mInterstitialAd = null
|
1707
1834
|
isInterstitialLoad = false
|
1708
|
-
|
1709
|
-
|
1835
|
+
val errorData = JSONObject().apply {
|
1836
|
+
put("code", adError.code)
|
1837
|
+
put("message", adError.message)
|
1838
|
+
put("domain", adError.domain)
|
1839
|
+
put("cause", adError.cause?.toString() ?: "null")
|
1840
|
+
}
|
1841
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.failed.show', ${errorData});")
|
1710
1842
|
}
|
1711
1843
|
|
1712
1844
|
override fun onAdImpression() {
|
@@ -1719,7 +1851,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1719
1851
|
}
|
1720
1852
|
}
|
1721
1853
|
|
1722
|
-
private fun rewardedAdLoadCallback(
|
1854
|
+
private fun rewardedAdLoadCallback() {
|
1723
1855
|
rewardedAd!!.fullScreenContentCallback = object : FullScreenContentCallback() {
|
1724
1856
|
override fun onAdClicked() {
|
1725
1857
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.click');")
|
@@ -1741,8 +1873,13 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1741
1873
|
override fun onAdFailedToShowFullScreenContent(adError: AdError) {
|
1742
1874
|
rewardedAd = null
|
1743
1875
|
isRewardedLoad = false
|
1744
|
-
|
1745
|
-
|
1876
|
+
val errorData = JSONObject().apply {
|
1877
|
+
put("code", adError.code)
|
1878
|
+
put("message", adError.message)
|
1879
|
+
put("domain", adError.domain)
|
1880
|
+
put("cause", adError.cause?.toString() ?: "null")
|
1881
|
+
}
|
1882
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.failed.show', ${errorData});")
|
1746
1883
|
}
|
1747
1884
|
|
1748
1885
|
override fun onAdImpression() {
|
@@ -1756,7 +1893,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1756
1893
|
}
|
1757
1894
|
}
|
1758
1895
|
|
1759
|
-
private fun rewardedInterstitialAdLoadCallback(
|
1896
|
+
private fun rewardedInterstitialAdLoadCallback() {
|
1760
1897
|
rewardedInterstitialAd!!.fullScreenContentCallback = object : FullScreenContentCallback() {
|
1761
1898
|
override fun onAdClicked() {
|
1762
1899
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.click');")
|
@@ -1778,8 +1915,13 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1778
1915
|
override fun onAdFailedToShowFullScreenContent(adError: AdError) {
|
1779
1916
|
rewardedInterstitialAd = null
|
1780
1917
|
isRewardedInterstitialLoad = false
|
1781
|
-
|
1782
|
-
|
1918
|
+
val errorData = JSONObject().apply {
|
1919
|
+
put("code", adError.code)
|
1920
|
+
put("message", adError.message)
|
1921
|
+
put("domain", adError.domain)
|
1922
|
+
put("cause", adError.cause?.toString() ?: "null")
|
1923
|
+
}
|
1924
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.failed.show', ${errorData});")
|
1783
1925
|
}
|
1784
1926
|
|
1785
1927
|
override fun onAdImpression() {
|
@@ -1800,7 +1942,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1800
1942
|
MobileAds.putPublisherFirstPartyIdEnabled(pubIdEnabled)
|
1801
1943
|
}
|
1802
1944
|
|
1803
|
-
private fun
|
1945
|
+
private fun targeting(
|
1804
1946
|
childDirectedTreatment: Boolean,
|
1805
1947
|
underAgeOfConsent: Boolean,
|
1806
1948
|
contentRating: String?
|
@@ -1843,7 +1985,9 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1843
1985
|
if (View::class.java.isAssignableFrom(CordovaWebView::class.java)) {
|
1844
1986
|
return cWebView as View?
|
1845
1987
|
}
|
1846
|
-
|
1988
|
+
|
1989
|
+
return mActivity!!.window.decorView.findViewById(View.generateViewId())
|
1990
|
+
// return mActivity!!.window.decorView.findViewById(R.id.content)
|
1847
1991
|
}
|
1848
1992
|
|
1849
1993
|
override fun onPause(multitasking: Boolean) {
|