@capgo/capacitor-admob 7.0.0

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.
Files changed (36) hide show
  1. package/CapgoCapacitorAdmob.podspec +17 -0
  2. package/Package.swift +28 -0
  3. package/README.md +232 -0
  4. package/android/build.gradle +68 -0
  5. package/android/src/main/AndroidManifest.xml +6 -0
  6. package/android/src/main/kotlin/admob/plus/capacitor/AdMobPlusPlugin.kt +147 -0
  7. package/android/src/main/kotlin/admob/plus/capacitor/ExecuteContext.kt +95 -0
  8. package/android/src/main/kotlin/admob/plus/capacitor/Generated.kt +42 -0
  9. package/android/src/main/kotlin/admob/plus/capacitor/ads/AdBase.kt +10 -0
  10. package/android/src/main/kotlin/admob/plus/capacitor/ads/Banner.kt +148 -0
  11. package/android/src/main/kotlin/admob/plus/capacitor/ads/Interstitial.kt +73 -0
  12. package/android/src/main/kotlin/admob/plus/capacitor/ads/Rewarded.kt +83 -0
  13. package/android/src/main/kotlin/admob/plus/capacitor/ads/RewardedInterstitial.kt +83 -0
  14. package/android/src/main/kotlin/admob/plus/core/Ad.kt +60 -0
  15. package/android/src/main/kotlin/admob/plus/core/Context.kt +149 -0
  16. package/android/src/main/kotlin/admob/plus/core/GenericAd.kt +21 -0
  17. package/android/src/main/kotlin/admob/plus/core/Helper.kt +119 -0
  18. package/android/src/main/res/.gitkeep +0 -0
  19. package/dist/docs.json +311 -0
  20. package/dist/esm/definitions.d.ts +53 -0
  21. package/dist/esm/definitions.js +16 -0
  22. package/dist/esm/definitions.js.map +1 -0
  23. package/dist/esm/index.d.ts +50 -0
  24. package/dist/esm/index.js +138 -0
  25. package/dist/esm/index.js.map +1 -0
  26. package/dist/esm/web.d.ts +16 -0
  27. package/dist/esm/web.js +40 -0
  28. package/dist/esm/web.js.map +1 -0
  29. package/dist/plugin.cjs.js +205 -0
  30. package/dist/plugin.cjs.js.map +1 -0
  31. package/dist/plugin.js +208 -0
  32. package/dist/plugin.js.map +1 -0
  33. package/ios/Sources/AdmobPlusPlugin/AdmobPlus.swift +8 -0
  34. package/ios/Sources/AdmobPlusPlugin/AdmobPlusPlugin.swift +19 -0
  35. package/ios/Tests/AdmobPlusPluginTests/AdmobPlusPluginTests.swift +12 -0
  36. package/package.json +83 -0
@@ -0,0 +1,148 @@
1
+ package admob.plus.capacitor.ads
2
+
3
+ import admob.plus.capacitor.AdMobPlusPlugin
4
+ import admob.plus.capacitor.ExecuteContext
5
+ import admob.plus.capacitor.Generated
6
+ import admob.plus.core.Context
7
+ import admob.plus.core.GenericAd
8
+ import admob.plus.core.Helper.Companion.getParentView
9
+ import admob.plus.core.Helper.Companion.removeFromParentView
10
+ import android.annotation.SuppressLint
11
+ import android.view.Gravity
12
+ import android.view.View
13
+ import android.view.ViewGroup
14
+ import android.webkit.WebView
15
+ import android.widget.LinearLayout
16
+ import com.google.android.gms.ads.AdListener
17
+ import com.google.android.gms.ads.AdSize
18
+ import com.google.android.gms.ads.AdView
19
+ import com.google.android.gms.ads.LoadAdError
20
+ import java.util.Objects
21
+
22
+ class Banner(ctx: ExecuteContext) : AdBase(ctx), GenericAd {
23
+ private val adSize: AdSize
24
+ private val gravity: Int
25
+ private var adView: AdView? = null
26
+
27
+ init {
28
+ adSize = AdSize.SMART_BANNER
29
+ gravity = if ("top" == ctx.optPosition()) Gravity.TOP else Gravity.BOTTOM
30
+ }
31
+
32
+ override val isLoaded: Boolean
33
+ get() = adView != null
34
+
35
+ override fun load(ctx: Context?) {
36
+ if (adView == null) {
37
+ adView = AdView(activity)
38
+ adView!!.adUnitId = adUnitId
39
+ // adView!!.adSize = adSize
40
+ adView!!.adListener = object : AdListener() {
41
+ override fun onAdClicked() {
42
+ emit(Generated.Events.BANNER_CLICK)
43
+ }
44
+
45
+ override fun onAdClosed() {
46
+ emit(Generated.Events.BANNER_CLOSE)
47
+ }
48
+
49
+ override fun onAdFailedToLoad(error: LoadAdError) {
50
+ emit(Generated.Events.BANNER_LOAD_FAIL, error)
51
+ }
52
+
53
+ override fun onAdImpression() {
54
+ emit(Generated.Events.BANNER_IMPRESSION)
55
+ }
56
+
57
+ override fun onAdLoaded() {
58
+ emit(Generated.Events.BANNER_LOAD)
59
+ }
60
+
61
+ override fun onAdOpened() {
62
+ emit(Generated.Events.BANNER_OPEN)
63
+ }
64
+ }
65
+ }
66
+ adView!!.loadAd(ctx!!.optAdRequest())
67
+ ctx.resolve()
68
+ }
69
+
70
+ override fun show(ctx: Context?) {
71
+ Objects.requireNonNull(adView)
72
+ val webView: WebView = ExecuteContext.Companion.plugin!!.getBridge().getWebView()
73
+ if (getParentView(adView) == null) {
74
+ addBannerView(ExecuteContext.Companion.plugin, adView)
75
+ } else if (adView!!.visibility == View.GONE) {
76
+ adView!!.resume()
77
+ adView!!.visibility = View.VISIBLE
78
+ } else {
79
+ val wvParentView = getParentView(webView)
80
+ if (parentView !== wvParentView) {
81
+ parentView!!.removeAllViews()
82
+ removeFromParentView(parentView)
83
+ addBannerView(ExecuteContext.Companion.plugin, adView)
84
+ }
85
+ }
86
+ ctx!!.resolve()
87
+ }
88
+
89
+ override fun hide(ctx: Context?) {
90
+ if (adView != null) {
91
+ adView!!.pause()
92
+ adView!!.visibility = View.GONE
93
+ }
94
+ ctx!!.resolve()
95
+ }
96
+
97
+ override fun destroy() {
98
+ if (adView != null) {
99
+ adView!!.destroy()
100
+ adView = null
101
+ }
102
+ super.destroy()
103
+ }
104
+
105
+ private fun addBannerView(plugin: AdMobPlusPlugin?, adView: AdView?) {
106
+ val webView = plugin!!.bridge.webView
107
+ val wvParentView = webView.parent as ViewGroup
108
+ if (parentView == null) {
109
+ parentView = LinearLayout(webView.context)
110
+ }
111
+ if (wvParentView != null && wvParentView !== parentView) {
112
+ if (getParentView(parentView) != null) {
113
+ parentView!!.removeAllViews()
114
+ removeFromParentView(parentView)
115
+ }
116
+ wvParentView.removeView(webView)
117
+ val content = parentView as LinearLayout?
118
+ content!!.orientation = LinearLayout.VERTICAL
119
+ content.setLayoutParams(
120
+ LinearLayout.LayoutParams(
121
+ ViewGroup.LayoutParams.MATCH_PARENT,
122
+ ViewGroup.LayoutParams.MATCH_PARENT,
123
+ 0.0f
124
+ )
125
+ )
126
+ webView.layoutParams = LinearLayout.LayoutParams(
127
+ ViewGroup.LayoutParams.MATCH_PARENT,
128
+ ViewGroup.LayoutParams.MATCH_PARENT,
129
+ 1.0f
130
+ )
131
+ content.addView(webView)
132
+ wvParentView.addView(parentView)
133
+ }
134
+ if (gravity == Gravity.TOP) {
135
+ parentView!!.addView(adView, 0)
136
+ } else {
137
+ parentView!!.addView(adView)
138
+ }
139
+ parentView!!.bringToFront()
140
+ parentView!!.requestLayout()
141
+ parentView!!.requestFocus()
142
+ }
143
+
144
+ companion object {
145
+ @SuppressLint("StaticFieldLeak")
146
+ private var parentView: ViewGroup? = null
147
+ }
148
+ }
@@ -0,0 +1,73 @@
1
+ package admob.plus.capacitor.ads
2
+
3
+ import admob.plus.capacitor.ExecuteContext
4
+ import admob.plus.capacitor.Generated
5
+ import admob.plus.core.Context
6
+ import admob.plus.core.GenericAd
7
+ import com.google.android.gms.ads.AdError
8
+ import com.google.android.gms.ads.FullScreenContentCallback
9
+ import com.google.android.gms.ads.LoadAdError
10
+ import com.google.android.gms.ads.interstitial.InterstitialAd
11
+ import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback
12
+
13
+ class Interstitial(ctx: ExecuteContext?) : AdBase(ctx), GenericAd {
14
+ private var mAd: InterstitialAd? = null
15
+ override fun destroy() {
16
+ clear()
17
+ super.destroy()
18
+ }
19
+
20
+ override fun load(ctx: Context?) {
21
+ clear()
22
+ InterstitialAd.load(
23
+ activity,
24
+ adUnitId,
25
+ ctx!!.optAdRequest(),
26
+ object : InterstitialAdLoadCallback() {
27
+ override fun onAdLoaded(interstitialAd: InterstitialAd) {
28
+ mAd = interstitialAd
29
+ mAd!!.fullScreenContentCallback = object : FullScreenContentCallback() {
30
+ override fun onAdDismissedFullScreenContent() {
31
+ clear()
32
+ emit(Generated.Events.INTERSTITIAL_DISMISS)
33
+ }
34
+
35
+ override fun onAdFailedToShowFullScreenContent(adError: AdError) {
36
+ emit(Generated.Events.INTERSTITIAL_SHOW_FAIL, adError)
37
+ }
38
+
39
+ override fun onAdShowedFullScreenContent() {
40
+ emit(Generated.Events.INTERSTITIAL_SHOW)
41
+ }
42
+
43
+ override fun onAdImpression() {
44
+ emit(Generated.Events.INTERSTITIAL_IMPRESSION)
45
+ }
46
+ }
47
+ emit(Generated.Events.INTERSTITIAL_LOAD)
48
+ ctx.resolve()
49
+ }
50
+
51
+ override fun onAdFailedToLoad(loadAdError: LoadAdError) {
52
+ clear()
53
+ emit(Generated.Events.INTERSTITIAL_LOAD_FAIL, loadAdError)
54
+ ctx.reject(loadAdError.message)
55
+ }
56
+ })
57
+ }
58
+
59
+ override val isLoaded: Boolean
60
+ get() = mAd != null
61
+
62
+ override fun show(ctx: Context?) {
63
+ mAd!!.show(activity)
64
+ ctx!!.resolve()
65
+ }
66
+
67
+ private fun clear() {
68
+ if (mAd != null) {
69
+ mAd!!.fullScreenContentCallback = null
70
+ mAd = null
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,83 @@
1
+ package admob.plus.capacitor.ads
2
+
3
+ import admob.plus.capacitor.ExecuteContext
4
+ import admob.plus.capacitor.Generated
5
+ import admob.plus.core.Context
6
+ import admob.plus.core.GenericAd
7
+ import com.google.android.gms.ads.AdError
8
+ import com.google.android.gms.ads.FullScreenContentCallback
9
+ import com.google.android.gms.ads.LoadAdError
10
+ import com.google.android.gms.ads.rewarded.RewardItem
11
+ import com.google.android.gms.ads.rewarded.RewardedAd
12
+ import com.google.android.gms.ads.rewarded.RewardedAdLoadCallback
13
+
14
+ class Rewarded(ctx: ExecuteContext?) : AdBase(ctx), GenericAd {
15
+ private var mAd: RewardedAd? = null
16
+ override fun destroy() {
17
+ clear()
18
+ super.destroy()
19
+ }
20
+
21
+ override fun load(ctx: Context?) {
22
+ clear()
23
+ RewardedAd.load(
24
+ activity,
25
+ adUnitId,
26
+ ctx!!.optAdRequest(),
27
+ object : RewardedAdLoadCallback() {
28
+ override fun onAdFailedToLoad(loadAdError: LoadAdError) {
29
+ clear()
30
+ emit(Generated.Events.REWARDED_LOAD_FAIL, loadAdError)
31
+ ctx.reject(loadAdError)
32
+ }
33
+
34
+ override fun onAdLoaded(rewardedAd: RewardedAd) {
35
+ mAd = rewardedAd
36
+ val ssv = ctx.optServerSideVerificationOptions()
37
+ if (ssv != null) {
38
+ mAd!!.setServerSideVerificationOptions(ssv)
39
+ }
40
+ mAd!!.fullScreenContentCallback = object : FullScreenContentCallback() {
41
+ override fun onAdDismissedFullScreenContent() {
42
+ clear()
43
+ emit(Generated.Events.REWARDED_DISMISS)
44
+ }
45
+
46
+ override fun onAdFailedToShowFullScreenContent(adError: AdError) {
47
+ emit(Generated.Events.REWARDED_SHOW_FAIL, adError)
48
+ }
49
+
50
+ override fun onAdShowedFullScreenContent() {
51
+ emit(Generated.Events.REWARDED_SHOW)
52
+ }
53
+
54
+ override fun onAdImpression() {
55
+ emit(Generated.Events.REWARDED_IMPRESSION)
56
+ }
57
+ }
58
+ emit(Generated.Events.REWARDED_LOAD)
59
+ ctx.resolve()
60
+ }
61
+ })
62
+ }
63
+
64
+ override val isLoaded: Boolean
65
+ get() = mAd != null
66
+
67
+ override fun show(ctx: Context?) {
68
+ mAd!!.show(activity) { rewardItem: RewardItem? ->
69
+ emit(
70
+ Generated.Events.REWARDED_REWARD,
71
+ rewardItem!!
72
+ )
73
+ }
74
+ ctx!!.resolve()
75
+ }
76
+
77
+ private fun clear() {
78
+ if (mAd != null) {
79
+ mAd!!.fullScreenContentCallback = null
80
+ mAd = null
81
+ }
82
+ }
83
+ }
@@ -0,0 +1,83 @@
1
+ package admob.plus.capacitor.ads
2
+
3
+ import admob.plus.capacitor.ExecuteContext
4
+ import admob.plus.capacitor.Generated
5
+ import admob.plus.core.Context
6
+ import admob.plus.core.GenericAd
7
+ import com.google.android.gms.ads.AdError
8
+ import com.google.android.gms.ads.FullScreenContentCallback
9
+ import com.google.android.gms.ads.LoadAdError
10
+ import com.google.android.gms.ads.rewarded.RewardItem
11
+ import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAd
12
+ import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAdLoadCallback
13
+
14
+ class RewardedInterstitial(ctx: ExecuteContext?) : AdBase(ctx), GenericAd {
15
+ private var mAd: RewardedInterstitialAd? = null
16
+ override fun destroy() {
17
+ clear()
18
+ super.destroy()
19
+ }
20
+
21
+ override fun load(ctx: Context?) {
22
+ clear()
23
+ RewardedInterstitialAd.load(
24
+ activity,
25
+ adUnitId,
26
+ ctx!!.optAdRequest(),
27
+ object : RewardedInterstitialAdLoadCallback() {
28
+ override fun onAdFailedToLoad(loadAdError: LoadAdError) {
29
+ clear()
30
+ emit(Generated.Events.REWARDED_INTERSTITIAL_LOAD_FAIL, loadAdError)
31
+ ctx.reject(loadAdError)
32
+ }
33
+
34
+ override fun onAdLoaded(rewardedAd: RewardedInterstitialAd) {
35
+ mAd = rewardedAd
36
+ val ssv = ctx.optServerSideVerificationOptions()
37
+ if (ssv != null) {
38
+ mAd!!.setServerSideVerificationOptions(ssv)
39
+ }
40
+ mAd!!.fullScreenContentCallback = object : FullScreenContentCallback() {
41
+ override fun onAdDismissedFullScreenContent() {
42
+ clear()
43
+ emit(Generated.Events.REWARDED_INTERSTITIAL_DISMISS)
44
+ }
45
+
46
+ override fun onAdFailedToShowFullScreenContent(adError: AdError) {
47
+ emit(Generated.Events.REWARDED_INTERSTITIAL_SHOW_FAIL, adError)
48
+ }
49
+
50
+ override fun onAdShowedFullScreenContent() {
51
+ emit(Generated.Events.REWARDED_INTERSTITIAL_SHOW)
52
+ }
53
+
54
+ override fun onAdImpression() {
55
+ emit(Generated.Events.REWARDED_INTERSTITIAL_IMPRESSION)
56
+ }
57
+ }
58
+ emit(Generated.Events.REWARDED_INTERSTITIAL_LOAD)
59
+ ctx.resolve()
60
+ }
61
+ })
62
+ }
63
+
64
+ override val isLoaded: Boolean
65
+ get() = mAd != null
66
+
67
+ override fun show(ctx: Context?) {
68
+ mAd!!.show(activity) { rewardItem: RewardItem? ->
69
+ emit(
70
+ Generated.Events.REWARDED_INTERSTITIAL_REWARD,
71
+ rewardItem!!
72
+ )
73
+ }
74
+ ctx!!.resolve()
75
+ }
76
+
77
+ private fun clear() {
78
+ if (mAd != null) {
79
+ mAd!!.fullScreenContentCallback = null
80
+ mAd = null
81
+ }
82
+ }
83
+ }
@@ -0,0 +1,60 @@
1
+ package admob.plus.core
2
+
3
+ import android.R
4
+ import android.app.Activity
5
+ import android.view.ViewGroup
6
+ import com.google.android.gms.ads.AdError
7
+ import com.google.android.gms.ads.rewarded.RewardItem
8
+ import java.util.Objects
9
+
10
+ abstract class Ad(val id: Int, val adUnitId: String) {
11
+ init {
12
+ Helper.ads.put(id, this)
13
+ }
14
+
15
+ constructor(ctx: Context) : this(
16
+ Objects.requireNonNull<Int?>(ctx.optId()),
17
+ Objects.requireNonNull<String?>(ctx.optAdUnitID())
18
+ )
19
+
20
+ open fun destroy() {
21
+ Helper.ads.remove(id)
22
+ }
23
+
24
+ protected abstract val adapter: Helper.Adapter
25
+ val activity: Activity
26
+ get() = adapter.activity
27
+ val contentView: ViewGroup?
28
+ get() = activity.findViewById(R.id.content)
29
+
30
+ protected fun emit(eventName: String?, error: AdError) {
31
+ this.emit(eventName, object : HashMap<String?, Any?>() {
32
+ init {
33
+ put("code", error.code)
34
+ put("message", error.message)
35
+ put("cause", error.cause)
36
+ }
37
+ })
38
+ }
39
+
40
+ protected fun emit(eventName: String?, rewardItem: RewardItem) {
41
+ this.emit(eventName, object : HashMap<String?, Any?>() {
42
+ init {
43
+ put("reward", object : HashMap<String?, Any?>() {
44
+ init {
45
+ put("amount", rewardItem.amount)
46
+ put("type", rewardItem.type)
47
+ }
48
+ })
49
+ }
50
+ })
51
+ }
52
+
53
+ protected fun emit(eventName: String?, data: Map<String?, Any?>? = HashMap()) {
54
+ adapter.emit(eventName, object : HashMap<String?, Any?>(data) {
55
+ init {
56
+ put("adId", id)
57
+ }
58
+ })
59
+ }
60
+ }
@@ -0,0 +1,149 @@
1
+ package admob.plus.core
2
+
3
+ import android.os.Bundle
4
+ import com.google.ads.mediation.admob.AdMobAdapter
5
+ import com.google.android.gms.ads.AdRequest
6
+ import com.google.android.gms.ads.LoadAdError
7
+ import com.google.android.gms.ads.MobileAds
8
+ import com.google.android.gms.ads.RequestConfiguration
9
+ import com.google.android.gms.ads.rewarded.ServerSideVerificationOptions
10
+ import org.json.JSONObject
11
+ import java.util.Objects
12
+
13
+ interface Context {
14
+ fun has(name: String): Boolean
15
+ fun opt(name: String): Any?
16
+ fun optBoolean(name: String): Boolean?
17
+ fun optDouble(name: String): Double?
18
+ fun optDouble(name: String, defaultValue: Double): Double {
19
+ return optDouble(name) ?: return defaultValue
20
+ }
21
+
22
+ fun optFloat(name: String): Float? {
23
+ val v = optDouble(name) ?: return null
24
+ return v.toFloat()
25
+ }
26
+
27
+ fun optInt(name: String): Int?
28
+ fun optString(name: String): String?
29
+ fun optStringList(name: String): List<String?>
30
+ fun optObject(name: String): JSONObject?
31
+ fun resolve()
32
+ fun resolve(data: Boolean)
33
+ fun reject(msg: String?)
34
+ fun reject() {
35
+ reject("unknown error")
36
+ }
37
+
38
+ fun reject(loadAdError: LoadAdError) {
39
+ reject(loadAdError.message)
40
+ }
41
+
42
+ fun optId(): Int? {
43
+ return optInt("id")
44
+ }
45
+
46
+ fun optAd(): Ad? {
47
+ return Helper.getAd(optId())
48
+ }
49
+
50
+ fun optAdOrError(): Ad? {
51
+ val ad = optAd()
52
+ if (ad == null) {
53
+ this.reject("Ad not found")
54
+ }
55
+ return ad
56
+ }
57
+
58
+ fun optAdUnitID(): String? {
59
+ return optString("adUnitId")
60
+ }
61
+
62
+ fun optAppMuted(): Boolean? {
63
+ return optBoolean("appMuted")
64
+ }
65
+
66
+ fun optAppVolume(): Float? {
67
+ return optFloat("appVolume")
68
+ }
69
+
70
+ fun optPosition(): String? {
71
+ return optString("position")
72
+ }
73
+
74
+ fun optAdRequest(): AdRequest {
75
+ val builder = AdRequest.Builder()
76
+ if (has("contentUrl")) {
77
+ Objects.requireNonNull(optString("contentUrl"))?.let { builder.setContentUrl(it) }
78
+ }
79
+ val extras = Bundle()
80
+ if (has("npa")) {
81
+ extras.putString("npa", optString("npa"))
82
+ }
83
+ return builder.addNetworkExtrasBundle(AdMobAdapter::class.java, extras).build()
84
+ }
85
+
86
+ fun optRequestConfiguration(): RequestConfiguration {
87
+ val builder = RequestConfiguration.Builder()
88
+ if (has("maxAdContentRating")) {
89
+ builder.setMaxAdContentRating(optString("maxAdContentRating"))
90
+ }
91
+ val tagForChildDirectedTreatment = intFromBool(
92
+ this, "tagForChildDirectedTreatment",
93
+ RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED,
94
+ RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE,
95
+ RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE
96
+ )
97
+ if (tagForChildDirectedTreatment != null) {
98
+ builder.setTagForChildDirectedTreatment(tagForChildDirectedTreatment)
99
+ }
100
+ val tagForUnderAgeOfConsent = intFromBool(
101
+ this, "tagForUnderAgeOfConsent",
102
+ RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED,
103
+ RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE,
104
+ RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_FALSE
105
+ )
106
+ if (tagForUnderAgeOfConsent != null) {
107
+ builder.setTagForUnderAgeOfConsent(tagForUnderAgeOfConsent)
108
+ }
109
+ if (has("testDeviceIds")) {
110
+ builder.setTestDeviceIds(optStringList("testDeviceIds"))
111
+ }
112
+ return builder.build()
113
+ }
114
+
115
+ fun optServerSideVerificationOptions(): ServerSideVerificationOptions? {
116
+ val param = "serverSideVerification"
117
+ val serverSideVerification = optObject(param) ?: return null
118
+ val builder = ServerSideVerificationOptions.Builder()
119
+ if (serverSideVerification.has("customData")) {
120
+ builder.setCustomData(serverSideVerification.optString("customData"))
121
+ }
122
+ if (serverSideVerification.has("userId")) {
123
+ builder.setUserId(serverSideVerification.optString("userId"))
124
+ }
125
+ return builder.build()
126
+ }
127
+
128
+ fun configure(helper: Helper) {
129
+ val appMuted = optAppMuted()
130
+ if (appMuted != null) {
131
+ MobileAds.setAppMuted(appMuted)
132
+ }
133
+ val appVolume = optAppVolume()
134
+ if (appVolume != null) {
135
+ MobileAds.setAppVolume(appVolume)
136
+ }
137
+ MobileAds.setRequestConfiguration(optRequestConfiguration())
138
+ helper.configForTestLab()
139
+ resolve()
140
+ }
141
+
142
+ companion object {
143
+ fun intFromBool(ctx: Context, name: String, vNull: Int, vTrue: Int, vFalse: Int): Int? {
144
+ if (!ctx.has(name)) return null
145
+ val v = ctx.optBoolean(name) ?: return vNull
146
+ return if (v) vTrue else vFalse
147
+ }
148
+ }
149
+ }
@@ -0,0 +1,21 @@
1
+ package admob.plus.core
2
+
3
+ interface GenericAd {
4
+ val isLoaded: Boolean
5
+ get() {
6
+ Helper.Companion.NOT_IMPLEMENTED()
7
+ return false
8
+ }
9
+
10
+ fun load(ctx: Context?) {
11
+ Helper.Companion.NOT_IMPLEMENTED()
12
+ }
13
+
14
+ fun show(ctx: Context?) {
15
+ Helper.Companion.NOT_IMPLEMENTED()
16
+ }
17
+
18
+ fun hide(ctx: Context?) {
19
+ Helper.Companion.NOT_IMPLEMENTED()
20
+ }
21
+ }