@capacitor-community/admob 3.0.1 → 3.3.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/CapacitorCommunityAdmob.podspec +1 -1
- package/LICENSE +1 -1
- package/README.md +137 -80
- package/android/build.gradle +11 -9
- package/android/src/main/java/com/getcapacitor/community/admob/AdMob.java +68 -15
- package/android/src/main/java/com/getcapacitor/community/admob/helpers/AuthorizationStatusEnum.kt +5 -0
- package/android/src/main/java/com/getcapacitor/community/admob/models/AdOptions.java +16 -2
- package/android/src/main/java/com/getcapacitor/community/admob/rewarded/AdRewardExecutor.java +1 -1
- package/android/src/main/java/com/getcapacitor/community/admob/rewarded/RewardedAdCallbackAndListeners.kt +14 -1
- package/android/src/main/java/com/getcapacitor/community/admob/rewarded/models/SsvInfo.kt +20 -0
- package/dist/docs.json +781 -92
- package/dist/esm/definitions.d.ts +50 -0
- package/dist/esm/definitions.js +19 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/reward/index.d.ts +1 -0
- package/dist/esm/reward/index.js +1 -0
- package/dist/esm/reward/index.js.map +1 -1
- package/dist/esm/reward/reward-ad-options.interface.d.ts +25 -0
- package/dist/esm/reward/reward-ad-options.interface.js +2 -0
- package/dist/esm/reward/reward-ad-options.interface.js.map +1 -0
- package/dist/esm/reward/reward-definitions.interface.d.ts +4 -3
- package/dist/esm/shared/tracking-authorization-status.interface.d.ts +6 -0
- package/dist/esm/shared/tracking-authorization-status.interface.js +2 -0
- package/dist/esm/shared/tracking-authorization-status.interface.js.map +1 -0
- package/dist/esm/web.d.ts +3 -0
- package/dist/esm/web.js +8 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +28 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +29 -1
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Banner/BannerExecutor.swift +1 -0
- package/ios/Plugin/Helper/AuthorizationStatusEnum.swift +6 -0
- package/ios/Plugin/Plugin.m +1 -0
- package/ios/Plugin/Plugin.swift +64 -3
- package/ios/Plugin/Rewarded/AdRewardExecutor.swift +17 -0
- package/package.json +4 -5
- package/ios/Plugin/.DS_Store +0 -0
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -6,15 +6,12 @@
|
|
|
6
6
|
</p>
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
|
9
|
-
<img src="https://img.shields.io/maintenance/yes/
|
|
9
|
+
<img src="https://img.shields.io/maintenance/yes/2022?style=flat-square" />
|
|
10
10
|
<!-- <a href="https://github.com/capacitor-community/example/actions?query=workflow%3A%22CI%22"><img src="https://img.shields.io/github/workflow/status/capacitor-community/example/CI?style=flat-square" /></a> -->
|
|
11
11
|
<a href="https://www.npmjs.com/package/@capacitor-community/admob"><img src="https://img.shields.io/npm/l/@capacitor-community/admob?style=flat-square" /></a>
|
|
12
12
|
<br>
|
|
13
13
|
<a href="https://www.npmjs.com/package/@capacitor-community/admob"><img src="https://img.shields.io/npm/dw/@capacitor-community/admob?style=flat-square" /></a>
|
|
14
14
|
<a href="https://www.npmjs.com/package/@capacitor-community/admob"><img src="https://img.shields.io/npm/v/@capacitor-community/admob?style=flat-square" /></a>
|
|
15
|
-
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
16
|
-
<a href="#contributors-"><img src="https://img.shields.io/badge/all%20contributors-4-orange?style=flat-square" /></a>
|
|
17
|
-
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
18
15
|
</p>
|
|
19
16
|
|
|
20
17
|
## Maintainers
|
|
@@ -26,9 +23,16 @@
|
|
|
26
23
|
|
|
27
24
|
Maintenance Status: Actively Maintained
|
|
28
25
|
|
|
26
|
+
## Contributors ✨
|
|
27
|
+
<a href="https://github.com/capacitor-community/admob/graphs/contributors">
|
|
28
|
+
<img src="https://contrib.rocks/image?repo=capacitor-community/admob" />
|
|
29
|
+
</a>
|
|
30
|
+
|
|
31
|
+
Made with [contributors-img](https://contrib.rocks).
|
|
32
|
+
|
|
29
33
|
## Demo
|
|
30
34
|
|
|
31
|
-
[Demo code is here.](https://github.com/capacitor-community/admob/tree/
|
|
35
|
+
[Demo code is here.](https://github.com/capacitor-community/admob/tree/master/demo)
|
|
32
36
|
|
|
33
37
|
### Screenshots
|
|
34
38
|
|
|
@@ -104,6 +108,21 @@ Don't forget to replace `[APP_ID]` by your AdMob application Id.
|
|
|
104
108
|
import { AdMob } from '@capacitor-community/admob';
|
|
105
109
|
|
|
106
110
|
export async function initialize(): Promise<void> {
|
|
111
|
+
const { status } = await AdMob.trackingAuthorizationStatus();
|
|
112
|
+
|
|
113
|
+
if (status === 'notDetermined') {
|
|
114
|
+
/**
|
|
115
|
+
* If you want to explain TrackingAuthorization before showing the iOS dialog,
|
|
116
|
+
* you can show the modal here.
|
|
117
|
+
* ex)
|
|
118
|
+
* const modal = await this.modalCtrl.create({
|
|
119
|
+
* component: RequestTrackingPage,
|
|
120
|
+
* });
|
|
121
|
+
* await modal.present();
|
|
122
|
+
* await modal.onDidDismiss(); // Wait for close modal
|
|
123
|
+
**/
|
|
124
|
+
}
|
|
125
|
+
|
|
107
126
|
AdMob.initialize({
|
|
108
127
|
requestTrackingAuthorization: true,
|
|
109
128
|
testingDevices: ['2077ef9a63d2b398840261c8221a0c9b'],
|
|
@@ -169,7 +188,7 @@ export async function interstitial(): Promise<void> {
|
|
|
169
188
|
### Show RewardVideo
|
|
170
189
|
|
|
171
190
|
```ts
|
|
172
|
-
import { AdMob,
|
|
191
|
+
import { AdMob, RewardAdOptions, AdLoadInfo, RewardAdPluginEvents, AdMobRewardItem } from '@capacitor-community/admob';
|
|
173
192
|
|
|
174
193
|
export async function rewardVideo(): Promise<void> {
|
|
175
194
|
AdMob.addListener(RewardAdPluginEvents.Loaded, (info: AdLoadInfo) => {
|
|
@@ -181,20 +200,57 @@ export async function rewardVideo(): Promise<void> {
|
|
|
181
200
|
console.log(rewardItem);
|
|
182
201
|
});
|
|
183
202
|
|
|
184
|
-
const options:
|
|
203
|
+
const options: RewardAdOptions = {
|
|
185
204
|
adId: 'YOUR ADID',
|
|
186
205
|
// isTesting: true
|
|
187
206
|
// npa: true
|
|
207
|
+
// ssv: {
|
|
208
|
+
// userId: "A user ID to send to your SSV"
|
|
209
|
+
// customData: JSON.stringify({ ...MyCustomData })
|
|
210
|
+
//}
|
|
188
211
|
};
|
|
189
212
|
await AdMob.prepareRewardVideoAd(options);
|
|
190
213
|
const rewardItem = await AdMob.showRewardVideoAd();
|
|
191
214
|
}
|
|
192
215
|
```
|
|
193
216
|
|
|
217
|
+
## Server-side Verification Notice
|
|
218
|
+
SSV callbacks are only fired on Production Adverts, therefore test Ads will not fire off your SSV callback.
|
|
219
|
+
|
|
220
|
+
For E2E tests or just for validating the data in your `RewardAdOptions` work as expected, you can add a custom GET
|
|
221
|
+
request to your mock endpoint after the `RewardAdPluginEvents.Rewarded` similar to this:
|
|
222
|
+
```ts
|
|
223
|
+
AdMob.addListener(RewardAdPluginEvents.Rewarded, async () => {
|
|
224
|
+
// ...
|
|
225
|
+
if (ENVIRONMENT_IS_DEVELOPMENT) {
|
|
226
|
+
try {
|
|
227
|
+
const url = `https://your-staging-ssv-endpoint` + new URLSearchParams({
|
|
228
|
+
'ad_network': 'TEST',
|
|
229
|
+
'ad_unit': 'TEST',
|
|
230
|
+
'custom_data': customData, // <-- passed CustomData
|
|
231
|
+
'reward_amount': 'TEST',
|
|
232
|
+
'reward_item': 'TEST',
|
|
233
|
+
'timestamp': 'TEST',
|
|
234
|
+
'transaction_id': 'TEST',
|
|
235
|
+
'user_id': userId, // <-- Passed UserID
|
|
236
|
+
'signature': 'TEST',
|
|
237
|
+
'key_id': 'TEST'
|
|
238
|
+
});
|
|
239
|
+
await fetch(url);
|
|
240
|
+
} catch (err) {
|
|
241
|
+
console.error(err);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// ...
|
|
245
|
+
});
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
|
|
194
249
|
## Index
|
|
195
250
|
<docgen-index>
|
|
196
251
|
|
|
197
252
|
* [`initialize(...)`](#initialize)
|
|
253
|
+
* [`trackingAuthorizationStatus()`](#trackingauthorizationstatus)
|
|
198
254
|
* [`showBanner(...)`](#showbanner)
|
|
199
255
|
* [`hideBanner()`](#hidebanner)
|
|
200
256
|
* [`resumeBanner()`](#resumebanner)
|
|
@@ -221,6 +277,7 @@ export async function rewardVideo(): Promise<void> {
|
|
|
221
277
|
* [`addListener(RewardAdPluginEvents.FailedToShow, ...)`](#addlistenerrewardadplugineventsfailedtoshow-)
|
|
222
278
|
* [`addListener(RewardAdPluginEvents.Showed, ...)`](#addlistenerrewardadplugineventsshowed-)
|
|
223
279
|
* [Interfaces](#interfaces)
|
|
280
|
+
* [Type Aliases](#type-aliases)
|
|
224
281
|
* [Enums](#enums)
|
|
225
282
|
|
|
226
283
|
</docgen-index>
|
|
@@ -241,7 +298,18 @@ Initialize AdMob with <a href="#admobinitializationoptions">AdMobInitializationO
|
|
|
241
298
|
| ------------- | --------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
242
299
|
| **`options`** | <code><a href="#admobinitializationoptions">AdMobInitializationOptions</a></code> | <a href="#admobinitializationoptions">AdMobInitializationOptions</a> |
|
|
243
300
|
|
|
244
|
-
|
|
301
|
+
--------------------
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
### trackingAuthorizationStatus()
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
trackingAuthorizationStatus() => Promise<TrackingAuthorizationStatusInterface>
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Confirm requestTrackingAuthorization status (iOS >14)
|
|
311
|
+
|
|
312
|
+
**Returns:** <code>Promise<<a href="#trackingauthorizationstatusinterface">TrackingAuthorizationStatusInterface</a>></code>
|
|
245
313
|
|
|
246
314
|
--------------------
|
|
247
315
|
|
|
@@ -258,8 +326,6 @@ Show a banner Ad
|
|
|
258
326
|
| ------------- | ----------------------------------------------------------- | ---------------------------------- |
|
|
259
327
|
| **`options`** | <code><a href="#banneradoptions">BannerAdOptions</a></code> | <a href="#adoptions">AdOptions</a> |
|
|
260
328
|
|
|
261
|
-
**Since:** 1.1.2
|
|
262
|
-
|
|
263
329
|
--------------------
|
|
264
330
|
|
|
265
331
|
|
|
@@ -271,8 +337,6 @@ hideBanner() => Promise<void>
|
|
|
271
337
|
|
|
272
338
|
Hide the banner, remove it from screen, but can show it later
|
|
273
339
|
|
|
274
|
-
**Since:** 1.1.2
|
|
275
|
-
|
|
276
340
|
--------------------
|
|
277
341
|
|
|
278
342
|
|
|
@@ -284,8 +348,6 @@ resumeBanner() => Promise<void>
|
|
|
284
348
|
|
|
285
349
|
Resume the banner, show it after hide
|
|
286
350
|
|
|
287
|
-
**Since:** 1.1.2
|
|
288
|
-
|
|
289
351
|
--------------------
|
|
290
352
|
|
|
291
353
|
|
|
@@ -297,8 +359,6 @@ removeBanner() => Promise<void>
|
|
|
297
359
|
|
|
298
360
|
Destroy the banner, remove it from screen.
|
|
299
361
|
|
|
300
|
-
**Since:** 1.1.2
|
|
301
|
-
|
|
302
362
|
--------------------
|
|
303
363
|
|
|
304
364
|
|
|
@@ -315,8 +375,6 @@ addListener(eventName: BannerAdPluginEvents.SizeChanged, listenerFunc: (info: Ad
|
|
|
315
375
|
|
|
316
376
|
**Returns:** <code><a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
|
|
317
377
|
|
|
318
|
-
**Since:** 3.0.0
|
|
319
|
-
|
|
320
378
|
--------------------
|
|
321
379
|
|
|
322
380
|
|
|
@@ -335,8 +393,6 @@ Notice: request loaded Banner ad
|
|
|
335
393
|
|
|
336
394
|
**Returns:** <code><a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
|
|
337
395
|
|
|
338
|
-
**Since:** 3.0.0
|
|
339
|
-
|
|
340
396
|
--------------------
|
|
341
397
|
|
|
342
398
|
|
|
@@ -355,8 +411,6 @@ Notice: request failed Banner ad
|
|
|
355
411
|
|
|
356
412
|
**Returns:** <code><a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
|
|
357
413
|
|
|
358
|
-
**Since:** 3.0.0
|
|
359
|
-
|
|
360
414
|
--------------------
|
|
361
415
|
|
|
362
416
|
|
|
@@ -375,8 +429,6 @@ Notice: full-screen banner view will be presented in response to the user clicki
|
|
|
375
429
|
|
|
376
430
|
**Returns:** <code><a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
|
|
377
431
|
|
|
378
|
-
**Since:** 3.0.0
|
|
379
|
-
|
|
380
432
|
--------------------
|
|
381
433
|
|
|
382
434
|
|
|
@@ -395,8 +447,6 @@ Notice: The full-screen banner view will been dismissed.
|
|
|
395
447
|
|
|
396
448
|
**Returns:** <code><a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
|
|
397
449
|
|
|
398
|
-
**Since:** 3.0.0
|
|
399
|
-
|
|
400
450
|
--------------------
|
|
401
451
|
|
|
402
452
|
|
|
@@ -415,8 +465,6 @@ Unimplemented
|
|
|
415
465
|
|
|
416
466
|
**Returns:** <code><a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
|
|
417
467
|
|
|
418
|
-
**Since:** 3.0.0
|
|
419
|
-
|
|
420
468
|
--------------------
|
|
421
469
|
|
|
422
470
|
|
|
@@ -434,8 +482,6 @@ Prepare interstitial banner
|
|
|
434
482
|
|
|
435
483
|
**Returns:** <code>Promise<<a href="#adloadinfo">AdLoadInfo</a>></code>
|
|
436
484
|
|
|
437
|
-
**Since:** 1.1.2
|
|
438
|
-
|
|
439
485
|
--------------------
|
|
440
486
|
|
|
441
487
|
|
|
@@ -447,8 +493,6 @@ showInterstitial() => Promise<void>
|
|
|
447
493
|
|
|
448
494
|
Show interstitial ad when it’s ready
|
|
449
495
|
|
|
450
|
-
**Since:** 1.1.2
|
|
451
|
-
|
|
452
496
|
--------------------
|
|
453
497
|
|
|
454
498
|
|
|
@@ -535,19 +579,17 @@ addListener(eventName: InterstitialAdPluginEvents.Showed, listenerFunc: () => vo
|
|
|
535
579
|
### prepareRewardVideoAd(...)
|
|
536
580
|
|
|
537
581
|
```typescript
|
|
538
|
-
prepareRewardVideoAd(options:
|
|
582
|
+
prepareRewardVideoAd(options: RewardAdOptions) => Promise<AdLoadInfo>
|
|
539
583
|
```
|
|
540
584
|
|
|
541
585
|
Prepare a reward video ad
|
|
542
586
|
|
|
543
|
-
| Param | Type
|
|
544
|
-
| ------------- |
|
|
545
|
-
| **`options`** | <code><a href="#
|
|
587
|
+
| Param | Type | Description |
|
|
588
|
+
| ------------- | ----------------------------------------------------------- | ---------------------------------------------- |
|
|
589
|
+
| **`options`** | <code><a href="#rewardadoptions">RewardAdOptions</a></code> | <a href="#rewardadoptions">RewardAdOptions</a> |
|
|
546
590
|
|
|
547
591
|
**Returns:** <code>Promise<<a href="#adloadinfo">AdLoadInfo</a>></code>
|
|
548
592
|
|
|
549
|
-
**Since:** 1.1.2
|
|
550
|
-
|
|
551
593
|
--------------------
|
|
552
594
|
|
|
553
595
|
|
|
@@ -561,8 +603,6 @@ Show a reward video ad
|
|
|
561
603
|
|
|
562
604
|
**Returns:** <code>Promise<<a href="#admobrewarditem">AdMobRewardItem</a>></code>
|
|
563
605
|
|
|
564
|
-
**Since:** 1.1.2
|
|
565
|
-
|
|
566
606
|
--------------------
|
|
567
607
|
|
|
568
608
|
|
|
@@ -667,21 +707,31 @@ addListener(eventName: RewardAdPluginEvents.Showed, listenerFunc: () => void) =>
|
|
|
667
707
|
|
|
668
708
|
#### AdMobInitializationOptions
|
|
669
709
|
|
|
670
|
-
| Prop | Type
|
|
671
|
-
| ---------------------------------- |
|
|
672
|
-
| **`requestTrackingAuthorization`** | <code>boolean</code>
|
|
673
|
-
| **`testingDevices`** | <code>string[]</code>
|
|
674
|
-
| **`initializeForTesting`** | <code>boolean</code>
|
|
710
|
+
| Prop | Type | Description |
|
|
711
|
+
| ---------------------------------- | ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
712
|
+
| **`requestTrackingAuthorization`** | <code>boolean</code> | Use or not requestTrackingAuthorization in iOS(>14) |
|
|
713
|
+
| **`testingDevices`** | <code>string[]</code> | An Array of devices IDs that will be marked as tested devices if {@link <a href="#admobinitializationoptions">AdMobInitializationOptions.initializeForTesting</a>} is true (Real Ads will be served to Testing devices but they will not count as 'real'). |
|
|
714
|
+
| **`initializeForTesting`** | <code>boolean</code> | If set to true, the devices on {@link <a href="#admobinitializationoptions">AdMobInitializationOptions.testingDevices</a>} will be registered to receive test production ads. |
|
|
715
|
+
| **`tagForChildDirectedTreatment`** | <code>boolean</code> | For purposes of the Children's Online Privacy Protection Act (COPPA), there is a setting called tagForChildDirectedTreatment. |
|
|
716
|
+
| **`tagForUnderAgeOfConsent`** | <code>boolean</code> | When using this feature, a Tag For Users under the Age of Consent in Europe (TFUA) parameter will be included in all future ad requests. |
|
|
717
|
+
| **`maxAdContentRating`** | <code><a href="#maxadcontentrating">MaxAdContentRating</a></code> | WAs an app developer, you can indicate whether you want Google to treat your content as child-directed when you make an ad request. |
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
#### TrackingAuthorizationStatusInterface
|
|
721
|
+
|
|
722
|
+
| Prop | Type |
|
|
723
|
+
| ------------ | ------------------------------------------------------------------------ |
|
|
724
|
+
| **`status`** | <code>'authorized' \| 'denied' \| 'notDetermined' \| 'restricted'</code> |
|
|
675
725
|
|
|
676
726
|
|
|
677
727
|
#### BannerAdOptions
|
|
678
728
|
|
|
679
729
|
This interface extends <a href="#adoptions">AdOptions</a>
|
|
680
730
|
|
|
681
|
-
| Prop | Type | Description |
|
|
682
|
-
| -------------- | ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
683
|
-
| **`adSize`** | <code><a href="#banneradsize">BannerAdSize</a></code> | Banner Ad Size, defaults to ADAPTIVE_BANNER. IT can be: ADAPTIVE_BANNER, SMART_BANNER, BANNER, MEDIUM_RECTANGLE, FULL_BANNER, LEADERBOARD |
|
|
684
|
-
| **`position`** | <code><a href="#banneradposition">BannerAdPosition</a></code> | Set Banner Ad position. TOP_CENTER or CENTER or BOTTOM_CENTER |
|
|
731
|
+
| Prop | Type | Description |
|
|
732
|
+
| -------------- | ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
733
|
+
| **`adSize`** | <code><a href="#banneradsize">BannerAdSize</a></code> | Banner Ad Size, defaults to ADAPTIVE_BANNER. IT can be: ADAPTIVE_BANNER, SMART_BANNER, BANNER, MEDIUM_RECTANGLE, FULL_BANNER, LEADERBOARD |
|
|
734
|
+
| **`position`** | <code><a href="#banneradposition">BannerAdPosition</a></code> | Set Banner Ad position. TOP_CENTER or CENTER or BOTTOM_CENTER |
|
|
685
735
|
|
|
686
736
|
|
|
687
737
|
#### PluginListenerHandle
|
|
@@ -721,12 +771,19 @@ https://developers.google.com/android/reference/com/google/android/gms/ads/AdErr
|
|
|
721
771
|
|
|
722
772
|
#### AdOptions
|
|
723
773
|
|
|
724
|
-
| Prop | Type | Description |
|
|
725
|
-
| --------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
726
|
-
| **`adId`** | <code>string</code> | The ad unit ID that you want to request |
|
|
727
|
-
| **`isTesting`** | <code>boolean</code> | You can use test mode of ad. |
|
|
728
|
-
| **`margin`** | <code>number</code> | Margin Banner. Default is 0px; If position is BOTTOM_CENTER, margin is be margin-bottom. If position is TOP_CENTER, margin is be margin-top. |
|
|
729
|
-
| **`npa`** | <code>boolean</code> | The default behavior of the Google Mobile Ads SDK is to serve personalized ads. Set this to true to request Non-Personalized Ads |
|
|
774
|
+
| Prop | Type | Description |
|
|
775
|
+
| --------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
776
|
+
| **`adId`** | <code>string</code> | The ad unit ID that you want to request |
|
|
777
|
+
| **`isTesting`** | <code>boolean</code> | You can use test mode of ad. |
|
|
778
|
+
| **`margin`** | <code>number</code> | Margin Banner. Default is 0px; If position is BOTTOM_CENTER, margin is be margin-bottom. If position is TOP_CENTER, margin is be margin-top. |
|
|
779
|
+
| **`npa`** | <code>boolean</code> | The default behavior of the Google Mobile Ads SDK is to serve personalized ads. Set this to true to request Non-Personalized Ads |
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
#### RewardAdOptions
|
|
783
|
+
|
|
784
|
+
| Prop | Type | Description |
|
|
785
|
+
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
786
|
+
| **`ssv`** | <code><a href="#atleastone">AtLeastOne</a><{ /** * An optional UserId to pass to your SSV callback function. */ userId: string; /** * An optional custom set of data to pass to your SSV callback function. */ customData: string; }></code> | If you have enabled SSV in your AdMob Application. You can provide customData or a userId be passed to your callback to do further processing on. *Important* You *HAVE* to define one of them. |
|
|
730
787
|
|
|
731
788
|
|
|
732
789
|
#### AdMobRewardItem
|
|
@@ -740,9 +797,34 @@ https://developers.google.com/admob/android/rewarded-video-adapters?hl=en
|
|
|
740
797
|
| **`amount`** | <code>number</code> | Rewarded amount user got |
|
|
741
798
|
|
|
742
799
|
|
|
800
|
+
### Type Aliases
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
#### AtLeastOne
|
|
804
|
+
|
|
805
|
+
<code>{[K in keyof T]: <a href="#pick">Pick</a><T, K>}[keyof T]</code>
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
#### Pick
|
|
809
|
+
|
|
810
|
+
From T, pick a set of properties whose keys are in the union K
|
|
811
|
+
|
|
812
|
+
<code>{
|
|
743
813
|
[P in K]: T[P];
|
|
744
814
|
}</code>
|
|
815
|
+
|
|
816
|
+
|
|
745
817
|
### Enums
|
|
746
818
|
|
|
747
819
|
|
|
820
|
+
#### MaxAdContentRating
|
|
821
|
+
|
|
822
|
+
| Members | Value | Description |
|
|
823
|
+
| ---------------------- | ------------------------------- | ----------------------------------------------------------- |
|
|
824
|
+
| **`General`** | <code>'General'</code> | Content suitable for general audiences, including families. |
|
|
825
|
+
| **`ParentalGuidance`** | <code>'ParentalGuidance'</code> | Content suitable for most audiences with parental guidance. |
|
|
826
|
+
| **`Teen`** | <code>'Teen'</code> | Content suitable for teen and older audiences. |
|
|
827
|
+
| **`MatureAudience`** | <code>'MatureAudience'</code> | Content suitable only for mature audiences. |
|
|
828
|
+
|
|
829
|
+
|
|
748
830
|
#### BannerAdSize
|
|
749
831
|
|
|
750
832
|
| Members | Value | Description |
|
|
@@ -813,28 +895,3 @@ You should run `pod repo update` ;
|
|
|
813
895
|
## License
|
|
814
896
|
|
|
815
897
|
Capacitor AdMob is [MIT licensed](./LICENSE).
|
|
816
|
-
|
|
817
|
-
## Contributors ✨
|
|
818
|
-
|
|
819
|
-
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
820
|
-
|
|
821
|
-
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
822
|
-
<!-- prettier-ignore-start -->
|
|
823
|
-
<!-- markdownlint-disable -->
|
|
824
|
-
<table>
|
|
825
|
-
<tr>
|
|
826
|
-
<td align="center"><a href="https://wako.app"><img src="https://avatars1.githubusercontent.com/u/216573?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jean-Baptiste Malatrasi</b></sub></a><br /><a href="https://github.com/capacitor-community/admob/commits?author=JumBay" title="Code">💻</a></td>
|
|
827
|
-
<td align="center"><a href="https://github.com/gant02"><img src="https://avatars1.githubusercontent.com/u/6771123?v=4?s=100" width="100px;" alt=""/><br /><sub><b>gant02</b></sub></a><br /><a href="https://github.com/capacitor-community/admob/commits?author=gant02" title="Code">💻</a></td>
|
|
828
|
-
<td align="center"><a href="https://www.saninnsalas.com"><img src="https://avatars1.githubusercontent.com/u/5490201?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Saninn Salas Diaz</b></sub></a><br /><a href="https://github.com/capacitor-community/admob/commits?author=distante" title="Code">💻</a></td>
|
|
829
|
-
<td align="center"><a href="https://www.nicolueg.com"><img src="https://avatars.githubusercontent.com/u/48101693?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nico Lueg</b></sub></a><br /><a href="https://github.com/capacitor-community/admob/commits?author=NLueg" title="Code">💻</a></td>
|
|
830
|
-
<td align="center"><a href="https://www.linkedin.com/in/ghonche-yqr-21774b114/"><img src="https://avatars.githubusercontent.com/u/25591295?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ghonche Yqr</b></sub></a><br /><a href="https://github.com/capacitor-community/admob/commits?author=ghonche-yqr" title="Documentation">📖</a></td>
|
|
831
|
-
<td align="center"><a href="https://github.com/vanessag"><img src="https://avatars.githubusercontent.com/u/4007550?v=4?s=100" width="100px;" alt=""/><br /><sub><b>vanessag</b></sub></a><br /><a href="https://github.com/capacitor-community/admob/commits?author=vanessag" title="Code">💻</a></td>
|
|
832
|
-
</tr>
|
|
833
|
-
</table>
|
|
834
|
-
|
|
835
|
-
<!-- markdownlint-restore -->
|
|
836
|
-
<!-- prettier-ignore-end -->
|
|
837
|
-
|
|
838
|
-
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
839
|
-
|
|
840
|
-
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
package/android/build.gradle
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
ext {
|
|
2
|
-
junitVersion =
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.1'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.2.0'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.2'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.3.0'
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
buildscript {
|
|
8
|
-
ext.kotlin_version = '1.
|
|
9
|
+
ext.kotlin_version = '1.5.21'
|
|
9
10
|
repositories {
|
|
10
11
|
google()
|
|
11
12
|
jcenter()
|
|
@@ -49,7 +50,7 @@ repositories {
|
|
|
49
50
|
mavenCentral()
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
def testRunner = "1.
|
|
53
|
+
def testRunner = "1.4.0"
|
|
53
54
|
|
|
54
55
|
dependencies {
|
|
55
56
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
@@ -70,14 +71,15 @@ dependencies {
|
|
|
70
71
|
// androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
71
72
|
// androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
implementation 'com.android.
|
|
74
|
+
// after 20.5.0, require minCompileSdk (31)
|
|
75
|
+
implementation 'com.google.android.gms:play-services-ads:20.4.0'
|
|
76
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
75
77
|
implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0"
|
|
76
|
-
implementation "androidx.core:core-ktx:1.
|
|
78
|
+
implementation "androidx.core:core-ktx:1.6.0"
|
|
77
79
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
// Allow to run unit test with ./gradlew test
|
|
81
83
|
tasks.withType(Test) {
|
|
82
84
|
useJUnitPlatform()
|
|
83
|
-
}
|
|
85
|
+
}
|
|
@@ -2,12 +2,14 @@ package com.getcapacitor.community.admob;
|
|
|
2
2
|
|
|
3
3
|
import android.Manifest;
|
|
4
4
|
import com.getcapacitor.JSArray;
|
|
5
|
+
import com.getcapacitor.JSObject;
|
|
5
6
|
import com.getcapacitor.Plugin;
|
|
6
7
|
import com.getcapacitor.PluginCall;
|
|
7
8
|
import com.getcapacitor.PluginMethod;
|
|
8
9
|
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
9
10
|
import com.getcapacitor.annotation.Permission;
|
|
10
11
|
import com.getcapacitor.community.admob.banner.BannerExecutor;
|
|
12
|
+
import com.getcapacitor.community.admob.helpers.AuthorizationStatusEnum;
|
|
11
13
|
import com.getcapacitor.community.admob.interstitial.AdInterstitialExecutor;
|
|
12
14
|
import com.getcapacitor.community.admob.interstitial.InterstitialAdCallbackAndListeners;
|
|
13
15
|
import com.getcapacitor.community.admob.rewarded.AdRewardExecutor;
|
|
@@ -47,14 +49,7 @@ public class AdMob extends Plugin {
|
|
|
47
49
|
// Initialize AdMob with appId
|
|
48
50
|
@PluginMethod
|
|
49
51
|
public void initialize(final PluginCall call) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (initializeForTesting) {
|
|
53
|
-
JSArray testingDevices = call.getArray("testingDevices", AdMob.EMPTY_TESTING_DEVICES);
|
|
54
|
-
this.setTestingDevicesTo(call, testingDevices);
|
|
55
|
-
} else {
|
|
56
|
-
this.setTestingDevicesTo(call, EMPTY_TESTING_DEVICES);
|
|
57
|
-
}
|
|
52
|
+
this.setRequestConfiguration(call);
|
|
58
53
|
|
|
59
54
|
try {
|
|
60
55
|
MobileAds.initialize(
|
|
@@ -71,6 +66,13 @@ public class AdMob extends Plugin {
|
|
|
71
66
|
}
|
|
72
67
|
}
|
|
73
68
|
|
|
69
|
+
@PluginMethod
|
|
70
|
+
public void trackingAuthorizationStatus(final PluginCall call) {
|
|
71
|
+
JSObject response = new JSObject();
|
|
72
|
+
response.put("status", AuthorizationStatusEnum.AUTHORIZED.getStatus());
|
|
73
|
+
call.resolve(response);
|
|
74
|
+
}
|
|
75
|
+
|
|
74
76
|
// Show a banner Ad
|
|
75
77
|
@PluginMethod
|
|
76
78
|
public void showBanner(final PluginCall call) {
|
|
@@ -117,18 +119,69 @@ public class AdMob extends Plugin {
|
|
|
117
119
|
}
|
|
118
120
|
|
|
119
121
|
/**
|
|
120
|
-
* An Array of devices IDs that will be marked as tested devices.
|
|
121
|
-
*
|
|
122
122
|
* @see <a href="https://developers.google.com/admob/android/test-ads#enable_test_devices">Test Devices</a>
|
|
123
|
+
* @see <a href="https://developers.google.com/admob/android/targeting">Target Settings</a>
|
|
123
124
|
*/
|
|
124
|
-
private void
|
|
125
|
-
//
|
|
125
|
+
private void setRequestConfiguration(final PluginCall call) {
|
|
126
|
+
// Testing Devices
|
|
127
|
+
final boolean initializeForTesting = call.getBoolean("initializeForTesting", false);
|
|
128
|
+
final JSArray testingDevices = initializeForTesting
|
|
129
|
+
? call.getArray("testingDevices", AdMob.EMPTY_TESTING_DEVICES)
|
|
130
|
+
: EMPTY_TESTING_DEVICES;
|
|
131
|
+
|
|
132
|
+
// tagForChildDirectedTreatment
|
|
133
|
+
final Boolean tagForChildDirectedTreatment = call.getBoolean("tagForChildDirectedTreatment");
|
|
134
|
+
int TAG_FOR_CHILD_DIRECTED_TREATMENT;
|
|
135
|
+
|
|
136
|
+
if (tagForChildDirectedTreatment == null) {
|
|
137
|
+
TAG_FOR_CHILD_DIRECTED_TREATMENT = RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED;
|
|
138
|
+
} else if (tagForChildDirectedTreatment) {
|
|
139
|
+
TAG_FOR_CHILD_DIRECTED_TREATMENT = RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE;
|
|
140
|
+
} else {
|
|
141
|
+
TAG_FOR_CHILD_DIRECTED_TREATMENT = RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// tagForUnderAgeOfConsent
|
|
145
|
+
final Boolean tagForUnderAgeOfConsent = call.getBoolean("tagForUnderAgeOfConsent");
|
|
146
|
+
int TAG_FOR_UNDER_AGE_OF_CONSENT;
|
|
147
|
+
|
|
148
|
+
if (tagForUnderAgeOfConsent == null) {
|
|
149
|
+
TAG_FOR_UNDER_AGE_OF_CONSENT = RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED;
|
|
150
|
+
} else if (tagForUnderAgeOfConsent) {
|
|
151
|
+
TAG_FOR_UNDER_AGE_OF_CONSENT = RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE;
|
|
152
|
+
} else {
|
|
153
|
+
TAG_FOR_UNDER_AGE_OF_CONSENT = RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_FALSE;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// maxAdContentRating
|
|
157
|
+
final String maxAdContentRating = call.getString("maxAdContentRating");
|
|
158
|
+
String MAX_AD_CONTENT_RATING = RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED;
|
|
159
|
+
|
|
160
|
+
if (maxAdContentRating != null) {
|
|
161
|
+
switch (maxAdContentRating) {
|
|
162
|
+
case "General":
|
|
163
|
+
MAX_AD_CONTENT_RATING = RequestConfiguration.MAX_AD_CONTENT_RATING_G;
|
|
164
|
+
break;
|
|
165
|
+
case "ParentalGuidance":
|
|
166
|
+
MAX_AD_CONTENT_RATING = RequestConfiguration.MAX_AD_CONTENT_RATING_PG;
|
|
167
|
+
break;
|
|
168
|
+
case "Teen":
|
|
169
|
+
MAX_AD_CONTENT_RATING = RequestConfiguration.MAX_AD_CONTENT_RATING_T;
|
|
170
|
+
break;
|
|
171
|
+
case "MatureAudience":
|
|
172
|
+
MAX_AD_CONTENT_RATING = RequestConfiguration.MAX_AD_CONTENT_RATING_MA;
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
126
177
|
try {
|
|
127
|
-
|
|
178
|
+
RequestConfiguration requestConfiguration = new RequestConfiguration.Builder()
|
|
128
179
|
.setTestDeviceIds(testingDevices.<String>toList())
|
|
180
|
+
.setTagForChildDirectedTreatment(TAG_FOR_CHILD_DIRECTED_TREATMENT)
|
|
181
|
+
.setTagForUnderAgeOfConsent(TAG_FOR_UNDER_AGE_OF_CONSENT)
|
|
182
|
+
.setMaxAdContentRating(MAX_AD_CONTENT_RATING)
|
|
129
183
|
.build();
|
|
130
|
-
|
|
131
|
-
MobileAds.setRequestConfiguration(configuration);
|
|
184
|
+
MobileAds.setRequestConfiguration(requestConfiguration);
|
|
132
185
|
} catch (JSONException error) {
|
|
133
186
|
call.reject(error.toString());
|
|
134
187
|
}
|