@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.
- package/CapgoCapacitorAdmob.podspec +17 -0
- package/Package.swift +28 -0
- package/README.md +232 -0
- package/android/build.gradle +68 -0
- package/android/src/main/AndroidManifest.xml +6 -0
- package/android/src/main/kotlin/admob/plus/capacitor/AdMobPlusPlugin.kt +147 -0
- package/android/src/main/kotlin/admob/plus/capacitor/ExecuteContext.kt +95 -0
- package/android/src/main/kotlin/admob/plus/capacitor/Generated.kt +42 -0
- package/android/src/main/kotlin/admob/plus/capacitor/ads/AdBase.kt +10 -0
- package/android/src/main/kotlin/admob/plus/capacitor/ads/Banner.kt +148 -0
- package/android/src/main/kotlin/admob/plus/capacitor/ads/Interstitial.kt +73 -0
- package/android/src/main/kotlin/admob/plus/capacitor/ads/Rewarded.kt +83 -0
- package/android/src/main/kotlin/admob/plus/capacitor/ads/RewardedInterstitial.kt +83 -0
- package/android/src/main/kotlin/admob/plus/core/Ad.kt +60 -0
- package/android/src/main/kotlin/admob/plus/core/Context.kt +149 -0
- package/android/src/main/kotlin/admob/plus/core/GenericAd.kt +21 -0
- package/android/src/main/kotlin/admob/plus/core/Helper.kt +119 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +311 -0
- package/dist/esm/definitions.d.ts +53 -0
- package/dist/esm/definitions.js +16 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +50 -0
- package/dist/esm/index.js +138 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +16 -0
- package/dist/esm/web.js +40 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +205 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +208 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/AdmobPlusPlugin/AdmobPlus.swift +8 -0
- package/ios/Sources/AdmobPlusPlugin/AdmobPlusPlugin.swift +19 -0
- package/ios/Tests/AdmobPlusPluginTests/AdmobPlusPluginTests.swift +12 -0
- package/package.json +83 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
package admob.plus.core
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import android.app.Activity
|
|
5
|
+
import android.content.res.Resources
|
|
6
|
+
import android.provider.Settings
|
|
7
|
+
import android.util.DisplayMetrics
|
|
8
|
+
import android.util.SparseArray
|
|
9
|
+
import android.view.View
|
|
10
|
+
import android.view.ViewGroup
|
|
11
|
+
import com.google.android.gms.ads.MobileAds
|
|
12
|
+
import org.json.JSONArray
|
|
13
|
+
import java.math.BigInteger
|
|
14
|
+
import java.security.MessageDigest
|
|
15
|
+
import java.security.NoSuchAlgorithmException
|
|
16
|
+
import java.util.Locale
|
|
17
|
+
|
|
18
|
+
class Helper(private val adapter: Adapter) {
|
|
19
|
+
val activity: Activity
|
|
20
|
+
get() = adapter.activity
|
|
21
|
+
val isRunningInTestLab: Boolean
|
|
22
|
+
get() {
|
|
23
|
+
val testLabSetting =
|
|
24
|
+
Settings.System.getString(activity.contentResolver, "firebase.test.lab")
|
|
25
|
+
return "true" == testLabSetting
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
fun configForTestLab() {
|
|
29
|
+
if (!isRunningInTestLab) {
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
val config = MobileAds.getRequestConfiguration()
|
|
33
|
+
val testDeviceIds = config.testDeviceIds
|
|
34
|
+
val deviceId = deviceId
|
|
35
|
+
if (testDeviceIds.contains(deviceId)) {
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
testDeviceIds.add(deviceId)
|
|
39
|
+
val builder = config.toBuilder()
|
|
40
|
+
builder.setTestDeviceIds(testDeviceIds)
|
|
41
|
+
MobileAds.setRequestConfiguration(builder.build())
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private val deviceId: String
|
|
45
|
+
private get() {
|
|
46
|
+
// This will request test ads on the emulator and device by passing this hashed device ID.
|
|
47
|
+
@SuppressLint("HardwareIds") val ANDROID_ID = Settings.Secure.getString(
|
|
48
|
+
activity.contentResolver, Settings.Secure.ANDROID_ID
|
|
49
|
+
)
|
|
50
|
+
return md5(ANDROID_ID).uppercase(Locale.getDefault())
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface Adapter {
|
|
54
|
+
val activity: Activity
|
|
55
|
+
fun emit(eventName: String?, data: Map<String?, Any?>?)
|
|
56
|
+
fun emit(eventName: String?) {
|
|
57
|
+
emit(eventName, HashMap())
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
companion object {
|
|
62
|
+
val ads = SparseArray<Ad>()
|
|
63
|
+
fun getAd(id: Int?): Ad {
|
|
64
|
+
return ads[id!!]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
fun dpToPx(dp: Double): Double {
|
|
68
|
+
return dp * Resources.getSystem().displayMetrics.density
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
fun pxToDp(px: Int): Int {
|
|
72
|
+
val displayMetrics =
|
|
73
|
+
Resources.getSystem().displayMetrics
|
|
74
|
+
return Math.round(px / (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT))
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@JvmStatic
|
|
78
|
+
fun jsonArray2stringList(a: JSONArray?): List<String> {
|
|
79
|
+
val result: MutableList<String> = ArrayList()
|
|
80
|
+
if (a == null) {
|
|
81
|
+
return result
|
|
82
|
+
}
|
|
83
|
+
for (i in 0 until a.length()) {
|
|
84
|
+
val testDeviceId = a.optString(i)
|
|
85
|
+
if (testDeviceId != null) {
|
|
86
|
+
result.add(testDeviceId)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return result
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@JvmStatic
|
|
93
|
+
fun getParentView(view: View?): ViewGroup? {
|
|
94
|
+
return if (view == null) null else view.parent as ViewGroup
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@JvmStatic
|
|
98
|
+
fun removeFromParentView(view: View?): ViewGroup? {
|
|
99
|
+
val viewParent = getParentView(view)
|
|
100
|
+
viewParent?.removeView(view)
|
|
101
|
+
return viewParent
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
fun NOT_IMPLEMENTED() {
|
|
105
|
+
throw UnsupportedOperationException("Not implemented.")
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private fun md5(s: String): String {
|
|
109
|
+
try {
|
|
110
|
+
val digest = MessageDigest.getInstance("MD5")
|
|
111
|
+
digest.update(s.toByteArray())
|
|
112
|
+
val bigInt = BigInteger(1, digest.digest())
|
|
113
|
+
return String.format("%32s", bigInt.toString(16)).replace(' ', '0')
|
|
114
|
+
} catch (ignore: NoSuchAlgorithmException) {
|
|
115
|
+
}
|
|
116
|
+
return ""
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "AdMobPlusPlugin",
|
|
4
|
+
"slug": "admobplusplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "start",
|
|
10
|
+
"signature": "() => Promise<void>",
|
|
11
|
+
"parameters": [],
|
|
12
|
+
"returns": "Promise<void>",
|
|
13
|
+
"tags": [],
|
|
14
|
+
"docs": "",
|
|
15
|
+
"complexTypes": [],
|
|
16
|
+
"slug": "start"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "configure",
|
|
20
|
+
"signature": "(config: AdMobConfig) => Promise<void>",
|
|
21
|
+
"parameters": [
|
|
22
|
+
{
|
|
23
|
+
"name": "config",
|
|
24
|
+
"docs": "",
|
|
25
|
+
"type": "AdMobConfig"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"returns": "Promise<void>",
|
|
29
|
+
"tags": [],
|
|
30
|
+
"docs": "",
|
|
31
|
+
"complexTypes": [
|
|
32
|
+
"AdMobConfig"
|
|
33
|
+
],
|
|
34
|
+
"slug": "configure"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "configRequest",
|
|
38
|
+
"signature": "(requestConfig: RequestConfig) => Promise<void>",
|
|
39
|
+
"parameters": [
|
|
40
|
+
{
|
|
41
|
+
"name": "requestConfig",
|
|
42
|
+
"docs": "",
|
|
43
|
+
"type": "RequestConfig"
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"returns": "Promise<void>",
|
|
47
|
+
"tags": [],
|
|
48
|
+
"docs": "",
|
|
49
|
+
"complexTypes": [
|
|
50
|
+
"RequestConfig"
|
|
51
|
+
],
|
|
52
|
+
"slug": "configrequest"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "adCreate",
|
|
56
|
+
"signature": "<O extends MobileAdOptions>(opts: O) => Promise<void>",
|
|
57
|
+
"parameters": [
|
|
58
|
+
{
|
|
59
|
+
"name": "opts",
|
|
60
|
+
"docs": "",
|
|
61
|
+
"type": "O"
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"returns": "Promise<void>",
|
|
65
|
+
"tags": [],
|
|
66
|
+
"docs": "",
|
|
67
|
+
"complexTypes": [
|
|
68
|
+
"MobileAdOptions",
|
|
69
|
+
"O"
|
|
70
|
+
],
|
|
71
|
+
"slug": "adcreate"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "adIsLoaded",
|
|
75
|
+
"signature": "(opts: { id: number; }) => Promise<boolean>",
|
|
76
|
+
"parameters": [
|
|
77
|
+
{
|
|
78
|
+
"name": "opts",
|
|
79
|
+
"docs": "",
|
|
80
|
+
"type": "{ id: number; }"
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
"returns": "Promise<boolean>",
|
|
84
|
+
"tags": [],
|
|
85
|
+
"docs": "",
|
|
86
|
+
"complexTypes": [],
|
|
87
|
+
"slug": "adisloaded"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "adLoad",
|
|
91
|
+
"signature": "(opts: { id: number; }) => Promise<void>",
|
|
92
|
+
"parameters": [
|
|
93
|
+
{
|
|
94
|
+
"name": "opts",
|
|
95
|
+
"docs": "",
|
|
96
|
+
"type": "{ id: number; }"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"returns": "Promise<void>",
|
|
100
|
+
"tags": [],
|
|
101
|
+
"docs": "",
|
|
102
|
+
"complexTypes": [],
|
|
103
|
+
"slug": "adload"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"name": "adShow",
|
|
107
|
+
"signature": "(opts: { id: number; }) => Promise<void>",
|
|
108
|
+
"parameters": [
|
|
109
|
+
{
|
|
110
|
+
"name": "opts",
|
|
111
|
+
"docs": "",
|
|
112
|
+
"type": "{ id: number; }"
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
"returns": "Promise<void>",
|
|
116
|
+
"tags": [],
|
|
117
|
+
"docs": "",
|
|
118
|
+
"complexTypes": [],
|
|
119
|
+
"slug": "adshow"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"name": "adHide",
|
|
123
|
+
"signature": "(opts: { id: number; }) => Promise<void>",
|
|
124
|
+
"parameters": [
|
|
125
|
+
{
|
|
126
|
+
"name": "opts",
|
|
127
|
+
"docs": "",
|
|
128
|
+
"type": "{ id: number; }"
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
"returns": "Promise<void>",
|
|
132
|
+
"tags": [],
|
|
133
|
+
"docs": "",
|
|
134
|
+
"complexTypes": [],
|
|
135
|
+
"slug": "adhide"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"name": "trackingAuthorizationStatus",
|
|
139
|
+
"signature": "() => Promise<{ status: TrackingAuthorizationStatus | false; }>",
|
|
140
|
+
"parameters": [],
|
|
141
|
+
"returns": "Promise<{ status: false | TrackingAuthorizationStatus; }>",
|
|
142
|
+
"tags": [],
|
|
143
|
+
"docs": "",
|
|
144
|
+
"complexTypes": [
|
|
145
|
+
"TrackingAuthorizationStatus"
|
|
146
|
+
],
|
|
147
|
+
"slug": "trackingauthorizationstatus"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"name": "requestTrackingAuthorization",
|
|
151
|
+
"signature": "() => Promise<{ status: TrackingAuthorizationStatus | false; }>",
|
|
152
|
+
"parameters": [],
|
|
153
|
+
"returns": "Promise<{ status: false | TrackingAuthorizationStatus; }>",
|
|
154
|
+
"tags": [],
|
|
155
|
+
"docs": "",
|
|
156
|
+
"complexTypes": [
|
|
157
|
+
"TrackingAuthorizationStatus"
|
|
158
|
+
],
|
|
159
|
+
"slug": "requesttrackingauthorization"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"name": "addListener",
|
|
163
|
+
"signature": "(eventName: string, listenerFunc: (event: any) => void) => Promise<PluginListenerHandle> & PluginListenerHandle",
|
|
164
|
+
"parameters": [
|
|
165
|
+
{
|
|
166
|
+
"name": "eventName",
|
|
167
|
+
"docs": "",
|
|
168
|
+
"type": "string"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"name": "listenerFunc",
|
|
172
|
+
"docs": "",
|
|
173
|
+
"type": "(event: any) => void"
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
"returns": "Promise<PluginListenerHandle> & PluginListenerHandle",
|
|
177
|
+
"tags": [],
|
|
178
|
+
"docs": "",
|
|
179
|
+
"complexTypes": [
|
|
180
|
+
"PluginListenerHandle"
|
|
181
|
+
],
|
|
182
|
+
"slug": "addlistenerstring-"
|
|
183
|
+
}
|
|
184
|
+
],
|
|
185
|
+
"properties": []
|
|
186
|
+
},
|
|
187
|
+
"interfaces": [
|
|
188
|
+
{
|
|
189
|
+
"name": "PluginListenerHandle",
|
|
190
|
+
"slug": "pluginlistenerhandle",
|
|
191
|
+
"docs": "",
|
|
192
|
+
"tags": [],
|
|
193
|
+
"methods": [],
|
|
194
|
+
"properties": [
|
|
195
|
+
{
|
|
196
|
+
"name": "remove",
|
|
197
|
+
"tags": [],
|
|
198
|
+
"docs": "",
|
|
199
|
+
"complexTypes": [],
|
|
200
|
+
"type": "() => Promise<void>"
|
|
201
|
+
}
|
|
202
|
+
]
|
|
203
|
+
}
|
|
204
|
+
],
|
|
205
|
+
"enums": [
|
|
206
|
+
{
|
|
207
|
+
"name": "MaxAdContentRating",
|
|
208
|
+
"slug": "maxadcontentrating",
|
|
209
|
+
"members": [
|
|
210
|
+
{
|
|
211
|
+
"name": "G",
|
|
212
|
+
"value": "'G'",
|
|
213
|
+
"tags": [],
|
|
214
|
+
"docs": ""
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"name": "MA",
|
|
218
|
+
"value": "'MA'",
|
|
219
|
+
"tags": [],
|
|
220
|
+
"docs": ""
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"name": "PG",
|
|
224
|
+
"value": "'PG'",
|
|
225
|
+
"tags": [],
|
|
226
|
+
"docs": ""
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"name": "T",
|
|
230
|
+
"value": "'T'",
|
|
231
|
+
"tags": [],
|
|
232
|
+
"docs": ""
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"name": "UNSPECIFIED",
|
|
236
|
+
"value": "''",
|
|
237
|
+
"tags": [],
|
|
238
|
+
"docs": ""
|
|
239
|
+
}
|
|
240
|
+
]
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"name": "TrackingAuthorizationStatus",
|
|
244
|
+
"slug": "trackingauthorizationstatus",
|
|
245
|
+
"members": [
|
|
246
|
+
{
|
|
247
|
+
"name": "notDetermined",
|
|
248
|
+
"value": "0",
|
|
249
|
+
"tags": [],
|
|
250
|
+
"docs": ""
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"name": "restricted",
|
|
254
|
+
"value": "1",
|
|
255
|
+
"tags": [],
|
|
256
|
+
"docs": ""
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"name": "denied",
|
|
260
|
+
"value": "2",
|
|
261
|
+
"tags": [],
|
|
262
|
+
"docs": ""
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"name": "authorized",
|
|
266
|
+
"value": "3",
|
|
267
|
+
"tags": [],
|
|
268
|
+
"docs": ""
|
|
269
|
+
}
|
|
270
|
+
]
|
|
271
|
+
}
|
|
272
|
+
],
|
|
273
|
+
"typeAliases": [
|
|
274
|
+
{
|
|
275
|
+
"name": "AdMobConfig",
|
|
276
|
+
"slug": "admobconfig",
|
|
277
|
+
"docs": "",
|
|
278
|
+
"types": [
|
|
279
|
+
{
|
|
280
|
+
"text": "{\n appMuted?: boolean;\n appVolume?: number;\n}",
|
|
281
|
+
"complexTypes": []
|
|
282
|
+
}
|
|
283
|
+
]
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"name": "RequestConfig",
|
|
287
|
+
"slug": "requestconfig",
|
|
288
|
+
"docs": "",
|
|
289
|
+
"types": [
|
|
290
|
+
{
|
|
291
|
+
"text": "{\n maxAdContentRating?: MaxAdContentRating;\n sameAppKey?: boolean;\n tagForChildDirectedTreatment?: boolean | null;\n tagForUnderAgeOfConsent?: boolean | null;\n testDeviceIds?: string[];\n}",
|
|
292
|
+
"complexTypes": [
|
|
293
|
+
"MaxAdContentRating"
|
|
294
|
+
]
|
|
295
|
+
}
|
|
296
|
+
]
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"name": "MobileAdOptions",
|
|
300
|
+
"slug": "mobileadoptions",
|
|
301
|
+
"docs": "",
|
|
302
|
+
"types": [
|
|
303
|
+
{
|
|
304
|
+
"text": "{ adUnitId: string }",
|
|
305
|
+
"complexTypes": []
|
|
306
|
+
}
|
|
307
|
+
]
|
|
308
|
+
}
|
|
309
|
+
],
|
|
310
|
+
"pluginConfigs": []
|
|
311
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { PluginListenerHandle } from '@capacitor/core';
|
|
2
|
+
export declare enum MaxAdContentRating {
|
|
3
|
+
G = "G",
|
|
4
|
+
MA = "MA",
|
|
5
|
+
PG = "PG",
|
|
6
|
+
T = "T",
|
|
7
|
+
UNSPECIFIED = ""
|
|
8
|
+
}
|
|
9
|
+
export type AdMobConfig = {
|
|
10
|
+
appMuted?: boolean;
|
|
11
|
+
appVolume?: number;
|
|
12
|
+
};
|
|
13
|
+
export type RequestConfig = {
|
|
14
|
+
maxAdContentRating?: MaxAdContentRating;
|
|
15
|
+
sameAppKey?: boolean;
|
|
16
|
+
tagForChildDirectedTreatment?: boolean | null;
|
|
17
|
+
tagForUnderAgeOfConsent?: boolean | null;
|
|
18
|
+
testDeviceIds?: string[];
|
|
19
|
+
};
|
|
20
|
+
export declare enum TrackingAuthorizationStatus {
|
|
21
|
+
notDetermined = 0,
|
|
22
|
+
restricted = 1,
|
|
23
|
+
denied = 2,
|
|
24
|
+
authorized = 3
|
|
25
|
+
}
|
|
26
|
+
export type MobileAdOptions = {
|
|
27
|
+
adUnitId: string;
|
|
28
|
+
};
|
|
29
|
+
export interface AdMobPlusPlugin {
|
|
30
|
+
start(): Promise<void>;
|
|
31
|
+
configure(config: AdMobConfig): Promise<void>;
|
|
32
|
+
configRequest(requestConfig: RequestConfig): Promise<void>;
|
|
33
|
+
adCreate<O extends MobileAdOptions>(opts: O): Promise<void>;
|
|
34
|
+
adIsLoaded(opts: {
|
|
35
|
+
id: number;
|
|
36
|
+
}): Promise<boolean>;
|
|
37
|
+
adLoad(opts: {
|
|
38
|
+
id: number;
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
adShow(opts: {
|
|
41
|
+
id: number;
|
|
42
|
+
}): Promise<void>;
|
|
43
|
+
adHide(opts: {
|
|
44
|
+
id: number;
|
|
45
|
+
}): Promise<void>;
|
|
46
|
+
trackingAuthorizationStatus(): Promise<{
|
|
47
|
+
status: TrackingAuthorizationStatus | false;
|
|
48
|
+
}>;
|
|
49
|
+
requestTrackingAuthorization(): Promise<{
|
|
50
|
+
status: TrackingAuthorizationStatus | false;
|
|
51
|
+
}>;
|
|
52
|
+
addListener(eventName: string, listenerFunc: (event: any) => void): Promise<PluginListenerHandle> & PluginListenerHandle;
|
|
53
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export var MaxAdContentRating;
|
|
2
|
+
(function (MaxAdContentRating) {
|
|
3
|
+
MaxAdContentRating["G"] = "G";
|
|
4
|
+
MaxAdContentRating["MA"] = "MA";
|
|
5
|
+
MaxAdContentRating["PG"] = "PG";
|
|
6
|
+
MaxAdContentRating["T"] = "T";
|
|
7
|
+
MaxAdContentRating["UNSPECIFIED"] = "";
|
|
8
|
+
})(MaxAdContentRating || (MaxAdContentRating = {}));
|
|
9
|
+
export var TrackingAuthorizationStatus;
|
|
10
|
+
(function (TrackingAuthorizationStatus) {
|
|
11
|
+
TrackingAuthorizationStatus[TrackingAuthorizationStatus["notDetermined"] = 0] = "notDetermined";
|
|
12
|
+
TrackingAuthorizationStatus[TrackingAuthorizationStatus["restricted"] = 1] = "restricted";
|
|
13
|
+
TrackingAuthorizationStatus[TrackingAuthorizationStatus["denied"] = 2] = "denied";
|
|
14
|
+
TrackingAuthorizationStatus[TrackingAuthorizationStatus["authorized"] = 3] = "authorized";
|
|
15
|
+
})(TrackingAuthorizationStatus || (TrackingAuthorizationStatus = {}));
|
|
16
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC5B,6BAAO,CAAA;IACP,+BAAS,CAAA;IACT,+BAAS,CAAA;IACT,6BAAO,CAAA;IACP,sCAAgB,CAAA;AAClB,CAAC,EANW,kBAAkB,KAAlB,kBAAkB,QAM7B;AAeD,MAAM,CAAN,IAAY,2BAKX;AALD,WAAY,2BAA2B;IACrC,+FAAiB,CAAA;IACjB,yFAAc,CAAA;IACd,iFAAU,CAAA;IACV,yFAAc,CAAA;AAChB,CAAC,EALW,2BAA2B,KAA3B,2BAA2B,QAKtC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { AdMobPlusPlugin, MobileAdOptions } from './definitions';
|
|
2
|
+
declare const AdMob: AdMobPlusPlugin;
|
|
3
|
+
declare class MobileAd<T extends MobileAdOptions = MobileAdOptions> {
|
|
4
|
+
#private;
|
|
5
|
+
private static allAds;
|
|
6
|
+
private static idCounter;
|
|
7
|
+
readonly id: number;
|
|
8
|
+
protected readonly opts: T;
|
|
9
|
+
constructor(opts: T);
|
|
10
|
+
private static nextId;
|
|
11
|
+
get adUnitId(): string;
|
|
12
|
+
protected isLoaded(): Promise<boolean>;
|
|
13
|
+
protected load(): Promise<void>;
|
|
14
|
+
protected show(): Promise<void>;
|
|
15
|
+
protected hide(): Promise<void>;
|
|
16
|
+
protected init(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
type Position = 'top' | 'bottom';
|
|
19
|
+
export interface BannerAdOptions extends MobileAdOptions {
|
|
20
|
+
position?: Position;
|
|
21
|
+
}
|
|
22
|
+
declare class BannerAd extends MobileAd {
|
|
23
|
+
#private;
|
|
24
|
+
static cls: string;
|
|
25
|
+
constructor(opts: BannerAdOptions);
|
|
26
|
+
isLoaded(): Promise<boolean>;
|
|
27
|
+
load(): Promise<void>;
|
|
28
|
+
show(): Promise<void>;
|
|
29
|
+
hide(): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
declare class InterstitialAd extends MobileAd {
|
|
32
|
+
static cls: string;
|
|
33
|
+
isLoaded(): Promise<boolean>;
|
|
34
|
+
load(): Promise<void>;
|
|
35
|
+
show(): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
declare class RewardedAd extends MobileAd {
|
|
38
|
+
static cls: string;
|
|
39
|
+
isLoaded(): Promise<boolean>;
|
|
40
|
+
load(): Promise<void>;
|
|
41
|
+
show(): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
declare class RewardedInterstitialAd extends MobileAd {
|
|
44
|
+
static cls: string;
|
|
45
|
+
isLoaded(): Promise<boolean>;
|
|
46
|
+
load(): Promise<void>;
|
|
47
|
+
show(): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
export * from './definitions';
|
|
50
|
+
export { AdMob, BannerAd, InterstitialAd, RewardedAd, RewardedInterstitialAd };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
+
};
|
|
12
|
+
var _MobileAd_created, _MobileAd_init, _BannerAd_loaded;
|
|
13
|
+
import { registerPlugin } from '@capacitor/core';
|
|
14
|
+
const AdMob = registerPlugin('AdMobPlus', {
|
|
15
|
+
web: () => import('./web').then((m) => new m.AdMobPlusWeb()),
|
|
16
|
+
});
|
|
17
|
+
let started = false;
|
|
18
|
+
let startPromise = null;
|
|
19
|
+
const start = AdMob.start;
|
|
20
|
+
AdMob.start = async () => {
|
|
21
|
+
startPromise = start();
|
|
22
|
+
const result = await startPromise;
|
|
23
|
+
started = true;
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
class MobileAd {
|
|
27
|
+
constructor(opts) {
|
|
28
|
+
_MobileAd_created.set(this, false);
|
|
29
|
+
_MobileAd_init.set(this, null);
|
|
30
|
+
this.opts = opts;
|
|
31
|
+
this.id = MobileAd.nextId();
|
|
32
|
+
MobileAd.allAds[this.id] = this;
|
|
33
|
+
}
|
|
34
|
+
static nextId() {
|
|
35
|
+
MobileAd.idCounter += 1;
|
|
36
|
+
return MobileAd.idCounter;
|
|
37
|
+
}
|
|
38
|
+
get adUnitId() {
|
|
39
|
+
return this.opts.adUnitId;
|
|
40
|
+
}
|
|
41
|
+
async isLoaded() {
|
|
42
|
+
await this.init();
|
|
43
|
+
return AdMob.adIsLoaded({ id: this.id });
|
|
44
|
+
}
|
|
45
|
+
async load() {
|
|
46
|
+
await this.init();
|
|
47
|
+
return AdMob.adLoad(Object.assign(Object.assign({}, this.opts), { id: this.id }));
|
|
48
|
+
}
|
|
49
|
+
async show() {
|
|
50
|
+
await this.init();
|
|
51
|
+
return AdMob.adShow({ id: this.id });
|
|
52
|
+
}
|
|
53
|
+
async hide() {
|
|
54
|
+
await this.init();
|
|
55
|
+
return AdMob.adHide({ id: this.id });
|
|
56
|
+
}
|
|
57
|
+
async init() {
|
|
58
|
+
var _a;
|
|
59
|
+
if (__classPrivateFieldGet(this, _MobileAd_created, "f"))
|
|
60
|
+
return;
|
|
61
|
+
if (!started) {
|
|
62
|
+
if (startPromise === null)
|
|
63
|
+
start();
|
|
64
|
+
await startPromise;
|
|
65
|
+
}
|
|
66
|
+
if (__classPrivateFieldGet(this, _MobileAd_init, "f") === null) {
|
|
67
|
+
const cls = (_a = this.constructor.cls) !== null && _a !== void 0 ? _a : this.constructor.name;
|
|
68
|
+
__classPrivateFieldSet(this, _MobileAd_init, AdMob.adCreate(Object.assign(Object.assign({}, this.opts), { id: this.id, cls })), "f");
|
|
69
|
+
}
|
|
70
|
+
await __classPrivateFieldGet(this, _MobileAd_init, "f");
|
|
71
|
+
__classPrivateFieldSet(this, _MobileAd_created, true, "f");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
_MobileAd_created = new WeakMap(), _MobileAd_init = new WeakMap();
|
|
75
|
+
MobileAd.allAds = {};
|
|
76
|
+
MobileAd.idCounter = 0;
|
|
77
|
+
class BannerAd extends MobileAd {
|
|
78
|
+
constructor(opts) {
|
|
79
|
+
super(Object.assign({ position: 'bottom' }, opts));
|
|
80
|
+
_BannerAd_loaded.set(this, false);
|
|
81
|
+
}
|
|
82
|
+
isLoaded() {
|
|
83
|
+
return super.isLoaded();
|
|
84
|
+
}
|
|
85
|
+
async load() {
|
|
86
|
+
await super.load();
|
|
87
|
+
__classPrivateFieldSet(this, _BannerAd_loaded, true, "f");
|
|
88
|
+
}
|
|
89
|
+
async show() {
|
|
90
|
+
if (!__classPrivateFieldGet(this, _BannerAd_loaded, "f"))
|
|
91
|
+
await this.load();
|
|
92
|
+
await super.show();
|
|
93
|
+
}
|
|
94
|
+
hide() {
|
|
95
|
+
return super.hide();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
_BannerAd_loaded = new WeakMap();
|
|
99
|
+
BannerAd.cls = 'BannerAd';
|
|
100
|
+
class InterstitialAd extends MobileAd {
|
|
101
|
+
isLoaded() {
|
|
102
|
+
return super.isLoaded();
|
|
103
|
+
}
|
|
104
|
+
async load() {
|
|
105
|
+
return super.load();
|
|
106
|
+
}
|
|
107
|
+
async show() {
|
|
108
|
+
return super.show();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
InterstitialAd.cls = 'InterstitialAd';
|
|
112
|
+
class RewardedAd extends MobileAd {
|
|
113
|
+
isLoaded() {
|
|
114
|
+
return super.isLoaded();
|
|
115
|
+
}
|
|
116
|
+
async load() {
|
|
117
|
+
return super.load();
|
|
118
|
+
}
|
|
119
|
+
async show() {
|
|
120
|
+
return super.show();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
RewardedAd.cls = 'RewardedAd';
|
|
124
|
+
class RewardedInterstitialAd extends MobileAd {
|
|
125
|
+
isLoaded() {
|
|
126
|
+
return super.isLoaded();
|
|
127
|
+
}
|
|
128
|
+
async load() {
|
|
129
|
+
return super.load();
|
|
130
|
+
}
|
|
131
|
+
async show() {
|
|
132
|
+
return super.show();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
RewardedInterstitialAd.cls = 'RewardedInterstitialAd';
|
|
136
|
+
export * from './definitions';
|
|
137
|
+
export { AdMob, BannerAd, InterstitialAd, RewardedAd, RewardedInterstitialAd };
|
|
138
|
+
//# sourceMappingURL=index.js.map
|