@capacitor-community/admob 6.0.0 → 6.1.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/README.md +261 -66
- package/android/src/main/java/com/getcapacitor/community/admob/AdMob.java +17 -0
- package/android/src/main/java/com/getcapacitor/community/admob/models/AdOptions.java +10 -0
- package/android/src/main/java/com/getcapacitor/community/admob/rewardedinterstitial/AdRewardInterstitialExecutor.java +84 -0
- package/android/src/main/java/com/getcapacitor/community/admob/rewardedinterstitial/RewardInterstitialAdPluginEvents.kt +12 -0
- package/android/src/main/java/com/getcapacitor/community/admob/rewardedinterstitial/RewardedInterstitialAdCallbackAndListeners.kt +50 -0
- package/android/src/main/java/com/getcapacitor/community/admob/rewardedinterstitial/models/SsvInfo.kt +20 -0
- package/dist/docs.json +340 -0
- package/dist/esm/definitions.d.ts +2 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/reward-interstitial/index.d.ts +4 -0
- package/dist/esm/reward-interstitial/index.js +5 -0
- package/dist/esm/reward-interstitial/index.js.map +1 -0
- package/dist/esm/reward-interstitial/reward-interstitial-ad-options.interface.d.ts +25 -0
- package/dist/esm/reward-interstitial/reward-interstitial-ad-options.interface.js +2 -0
- package/dist/esm/reward-interstitial/reward-interstitial-ad-options.interface.js.map +1 -0
- package/dist/esm/reward-interstitial/reward-interstitial-ad-plugin-events.enum.d.ts +32 -0
- package/dist/esm/reward-interstitial/reward-interstitial-ad-plugin-events.enum.js +35 -0
- package/dist/esm/reward-interstitial/reward-interstitial-ad-plugin-events.enum.js.map +1 -0
- package/dist/esm/reward-interstitial/reward-interstitial-definitions.interface.d.ts +30 -0
- package/dist/esm/reward-interstitial/reward-interstitial-definitions.interface.js +2 -0
- package/dist/esm/reward-interstitial/reward-interstitial-definitions.interface.js.map +1 -0
- package/dist/esm/reward-interstitial/reward-interstitial-item.interface.d.ts +14 -0
- package/dist/esm/reward-interstitial/reward-interstitial-item.interface.js +2 -0
- package/dist/esm/reward-interstitial/reward-interstitial-item.interface.js.map +1 -0
- package/dist/esm/web.d.ts +2 -0
- package/dist/esm/web.js +12 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +47 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +47 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Banner/BannerExecutor.swift +7 -7
- package/ios/Plugin/Consent/ConsentExecutor.swift +1 -1
- package/ios/Plugin/Interstitial/AdInterstitialExecutor.swift +4 -4
- package/ios/Plugin/Plugin.m +2 -0
- package/ios/Plugin/Plugin.swift +24 -2
- package/ios/Plugin/Rewarded/AdRewardExecutor.swift +4 -4
- package/ios/Plugin/RewardedInterstitial/AdRewardInterstitialExecutor.swift +86 -0
- package/ios/Plugin/RewardedInterstitial/RewardInterstitialAdPluginEvents.swift +8 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
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/2024?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>
|
|
@@ -16,14 +16,15 @@
|
|
|
16
16
|
|
|
17
17
|
## Maintainers
|
|
18
18
|
|
|
19
|
-
| Maintainer | GitHub
|
|
20
|
-
| ------------------- |
|
|
21
|
-
| Masahiko Sakakibara | [rdlabo](https://github.com/rdlabo)
|
|
22
|
-
| Saninn Salas Diaz
|
|
19
|
+
| Maintainer | GitHub | Social | Sponsoring Company |
|
|
20
|
+
| ------------------- | ------------------------------------------------ | ----------------------------------------------- | ---------------------------------------------- |
|
|
21
|
+
| Masahiko Sakakibara | [rdlabo](https://github.com/rdlabo) | [@rdlabo](https://twitter.com/rdlabo) | RELATION DESIGN LABO, GENERAL INC. ASSOCIATION |
|
|
22
|
+
| Saninn Salas Diaz | [Saninn Salas Diaz](https://github.com/distante) | [@SaninnSalas](https://twitter.com/SaninnSalas) | |
|
|
23
23
|
|
|
24
24
|
Maintenance Status: Actively Maintained
|
|
25
25
|
|
|
26
26
|
## Contributors ✨
|
|
27
|
+
|
|
27
28
|
<a href="https://github.com/capacitor-community/admob/graphs/contributors">
|
|
28
29
|
<img src="https://contrib.rocks/image?repo=capacitor-community/admob" />
|
|
29
30
|
</a>
|
|
@@ -42,6 +43,7 @@ Made with [contributors-img](https://contrib.rocks).
|
|
|
42
43
|
| **Android** |  |  |  |
|
|
43
44
|
|
|
44
45
|
## Installation
|
|
46
|
+
|
|
45
47
|
If you use capacitor 5:
|
|
46
48
|
|
|
47
49
|
```
|
|
@@ -119,39 +121,39 @@ import { AdMob } from '@capacitor-community/admob';
|
|
|
119
121
|
|
|
120
122
|
export async function initialize(): Promise<void> {
|
|
121
123
|
await AdMob.initialize();
|
|
122
|
-
|
|
124
|
+
|
|
123
125
|
const [trackingInfo, consentInfo] = await Promise.all([
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
AdMob.trackingAuthorizationStatus(),
|
|
127
|
+
AdMob.requestConsentInfo(),
|
|
126
128
|
]);
|
|
127
|
-
|
|
129
|
+
|
|
128
130
|
if (trackingInfo.status === 'notDetermined') {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
131
|
+
/**
|
|
132
|
+
* If you want to explain TrackingAuthorization before showing the iOS dialog,
|
|
133
|
+
* you can show the modal here.
|
|
134
|
+
* ex)
|
|
135
|
+
* const modal = await this.modalCtrl.create({
|
|
136
|
+
* component: RequestTrackingPage,
|
|
137
|
+
* });
|
|
138
|
+
* await modal.present();
|
|
139
|
+
* await modal.onDidDismiss(); // Wait for close modal
|
|
140
|
+
**/
|
|
141
|
+
|
|
142
|
+
await AdMob.requestTrackingAuthorization();
|
|
141
143
|
}
|
|
142
144
|
|
|
143
145
|
const authorizationStatus = await AdMob.trackingAuthorizationStatus();
|
|
144
146
|
if (
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
authorizationStatus.status === 'authorized' &&
|
|
148
|
+
consentInfo.isConsentFormAvailable &&
|
|
149
|
+
consentInfo.status === AdmobConsentStatus.REQUIRED
|
|
148
150
|
) {
|
|
149
|
-
|
|
151
|
+
await AdMob.showConsentForm();
|
|
150
152
|
}
|
|
151
153
|
}
|
|
152
154
|
```
|
|
153
155
|
|
|
154
|
-
Send
|
|
156
|
+
Send an array of device Ids in `testingDevices` to use production like ads on your specified devices -> https://developers.google.com/admob/android/test-ads#enable_test_devices
|
|
155
157
|
|
|
156
158
|
### User Message Platform (UMP)
|
|
157
159
|
|
|
@@ -180,10 +182,10 @@ async showConsent() {
|
|
|
180
182
|
If you testing on real device, you have to set `debugGeography` and add your device ID to `testDeviceIdentifiers`. You can find your device ID with logcat (Android) or XCode (iOS).
|
|
181
183
|
|
|
182
184
|
```ts
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
const consentInfo = await AdMob.requestConsentInfo({
|
|
186
|
+
debugGeography: AdmobConsentDebugGeography.EEA,
|
|
187
|
+
testDeviceIdentifiers: ['YOUR_DEVICE_ID'],
|
|
188
|
+
});
|
|
187
189
|
```
|
|
188
190
|
|
|
189
191
|
**Note**: When testing, if you choose not consent (Manage -> Confirm Choices). The ads may not load/show. Even on testing enviroment. This is normal. It will work on Production so don't worry.
|
|
@@ -193,38 +195,53 @@ If you testing on real device, you have to set `debugGeography` and add your dev
|
|
|
193
195
|
1. AdMob.initialize
|
|
194
196
|
2. AdMob.requestConsentInfo
|
|
195
197
|
3. AdMob.showConsentForm (If consent form required )
|
|
196
|
-
3/ AdMob.showBanner
|
|
198
|
+
3/ AdMob.showBanner
|
|
197
199
|
|
|
198
200
|
### Show Banner
|
|
199
201
|
|
|
200
202
|
```ts
|
|
201
|
-
import {
|
|
203
|
+
import {
|
|
204
|
+
AdMob,
|
|
205
|
+
BannerAdOptions,
|
|
206
|
+
BannerAdSize,
|
|
207
|
+
BannerAdPosition,
|
|
208
|
+
BannerAdPluginEvents,
|
|
209
|
+
AdMobBannerSize,
|
|
210
|
+
} from '@capacitor-community/admob';
|
|
202
211
|
|
|
203
212
|
export async function banner(): Promise<void> {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
213
|
+
AdMob.addListener(BannerAdPluginEvents.Loaded, () => {
|
|
214
|
+
// Subscribe Banner Event Listener
|
|
215
|
+
});
|
|
207
216
|
|
|
208
|
-
|
|
217
|
+
AdMob.addListener(
|
|
218
|
+
BannerAdPluginEvents.SizeChanged,
|
|
219
|
+
(size: AdMobBannerSize) => {
|
|
209
220
|
// Subscribe Change Banner Size
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
+
},
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
const options: BannerAdOptions = {
|
|
225
|
+
adId: 'YOUR ADID',
|
|
226
|
+
adSize: BannerAdSize.BANNER,
|
|
227
|
+
position: BannerAdPosition.BOTTOM_CENTER,
|
|
228
|
+
margin: 0,
|
|
229
|
+
// isTesting: true
|
|
230
|
+
// npa: true
|
|
231
|
+
};
|
|
232
|
+
AdMob.showBanner(options);
|
|
221
233
|
}
|
|
222
234
|
```
|
|
223
235
|
|
|
224
236
|
### Show Interstitial
|
|
225
237
|
|
|
226
238
|
```ts
|
|
227
|
-
import {
|
|
239
|
+
import {
|
|
240
|
+
AdMob,
|
|
241
|
+
AdOptions,
|
|
242
|
+
AdLoadInfo,
|
|
243
|
+
InterstitialAdPluginEvents,
|
|
244
|
+
} from '@capacitor-community/admob';
|
|
228
245
|
|
|
229
246
|
export async function interstitial(): Promise<void> {
|
|
230
247
|
AdMob.addListener(InterstitialAdPluginEvents.Loaded, (info: AdLoadInfo) => {
|
|
@@ -244,17 +261,26 @@ export async function interstitial(): Promise<void> {
|
|
|
244
261
|
### Show RewardVideo
|
|
245
262
|
|
|
246
263
|
```ts
|
|
247
|
-
import {
|
|
264
|
+
import {
|
|
265
|
+
AdMob,
|
|
266
|
+
RewardAdOptions,
|
|
267
|
+
AdLoadInfo,
|
|
268
|
+
RewardAdPluginEvents,
|
|
269
|
+
AdMobRewardItem,
|
|
270
|
+
} from '@capacitor-community/admob';
|
|
248
271
|
|
|
249
272
|
export async function rewardVideo(): Promise<void> {
|
|
250
273
|
AdMob.addListener(RewardAdPluginEvents.Loaded, (info: AdLoadInfo) => {
|
|
251
274
|
// Subscribe prepared rewardVideo
|
|
252
275
|
});
|
|
253
276
|
|
|
254
|
-
AdMob.addListener(
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
277
|
+
AdMob.addListener(
|
|
278
|
+
RewardAdPluginEvents.Rewarded,
|
|
279
|
+
(rewardItem: AdMobRewardItem) => {
|
|
280
|
+
// Subscribe user rewarded
|
|
281
|
+
console.log(rewardItem);
|
|
282
|
+
},
|
|
283
|
+
);
|
|
258
284
|
|
|
259
285
|
const options: RewardAdOptions = {
|
|
260
286
|
adId: 'YOUR ADID',
|
|
@@ -271,27 +297,31 @@ export async function rewardVideo(): Promise<void> {
|
|
|
271
297
|
```
|
|
272
298
|
|
|
273
299
|
## Server-side Verification Notice
|
|
300
|
+
|
|
274
301
|
SSV callbacks are only fired on Production Adverts, therefore test Ads will not fire off your SSV callback.
|
|
275
302
|
|
|
276
303
|
For E2E tests or just for validating the data in your `RewardAdOptions` work as expected, you can add a custom GET
|
|
277
304
|
request to your mock endpoint after the `RewardAdPluginEvents.Rewarded` similar to this:
|
|
305
|
+
|
|
278
306
|
```ts
|
|
279
307
|
AdMob.addListener(RewardAdPluginEvents.Rewarded, async () => {
|
|
280
308
|
// ...
|
|
281
309
|
if (ENVIRONMENT_IS_DEVELOPMENT) {
|
|
282
310
|
try {
|
|
283
|
-
const url =
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
311
|
+
const url =
|
|
312
|
+
`https://your-staging-ssv-endpoint` +
|
|
313
|
+
new URLSearchParams({
|
|
314
|
+
ad_network: 'TEST',
|
|
315
|
+
ad_unit: 'TEST',
|
|
316
|
+
custom_data: customData, // <-- passed CustomData
|
|
317
|
+
reward_amount: 'TEST',
|
|
318
|
+
reward_item: 'TEST',
|
|
319
|
+
timestamp: 'TEST',
|
|
320
|
+
transaction_id: 'TEST',
|
|
321
|
+
user_id: userId, // <-- Passed UserID
|
|
322
|
+
signature: 'TEST',
|
|
323
|
+
key_id: 'TEST',
|
|
324
|
+
});
|
|
295
325
|
await fetch(url);
|
|
296
326
|
} catch (err) {
|
|
297
327
|
console.error(err);
|
|
@@ -301,8 +331,8 @@ AdMob.addListener(RewardAdPluginEvents.Rewarded, async () => {
|
|
|
301
331
|
});
|
|
302
332
|
```
|
|
303
333
|
|
|
304
|
-
|
|
305
334
|
## Index
|
|
335
|
+
|
|
306
336
|
<docgen-index>
|
|
307
337
|
|
|
308
338
|
* [`initialize(...)`](#initialize)
|
|
@@ -338,6 +368,14 @@ AdMob.addListener(RewardAdPluginEvents.Rewarded, async () => {
|
|
|
338
368
|
* [`addListener(RewardAdPluginEvents.Dismissed, ...)`](#addlistenerrewardadplugineventsdismissed-)
|
|
339
369
|
* [`addListener(RewardAdPluginEvents.FailedToShow, ...)`](#addlistenerrewardadplugineventsfailedtoshow-)
|
|
340
370
|
* [`addListener(RewardAdPluginEvents.Showed, ...)`](#addlistenerrewardadplugineventsshowed-)
|
|
371
|
+
* [`prepareRewardInterstitialAd(...)`](#preparerewardinterstitialad)
|
|
372
|
+
* [`showRewardInterstitialAd()`](#showrewardinterstitialad)
|
|
373
|
+
* [`addListener(RewardInterstitialAdPluginEvents.FailedToLoad, ...)`](#addlistenerrewardinterstitialadplugineventsfailedtoload-)
|
|
374
|
+
* [`addListener(RewardInterstitialAdPluginEvents.Loaded, ...)`](#addlistenerrewardinterstitialadplugineventsloaded-)
|
|
375
|
+
* [`addListener(RewardInterstitialAdPluginEvents.Rewarded, ...)`](#addlistenerrewardinterstitialadplugineventsrewarded-)
|
|
376
|
+
* [`addListener(RewardInterstitialAdPluginEvents.Dismissed, ...)`](#addlistenerrewardinterstitialadplugineventsdismissed-)
|
|
377
|
+
* [`addListener(RewardInterstitialAdPluginEvents.FailedToShow, ...)`](#addlistenerrewardinterstitialadplugineventsfailedtoshow-)
|
|
378
|
+
* [`addListener(RewardInterstitialAdPluginEvents.Showed, ...)`](#addlistenerrewardinterstitialadplugineventsshowed-)
|
|
341
379
|
* [Interfaces](#interfaces)
|
|
342
380
|
* [Type Aliases](#type-aliases)
|
|
343
381
|
* [Enums](#enums)
|
|
@@ -345,6 +383,7 @@ AdMob.addListener(RewardAdPluginEvents.Rewarded, async () => {
|
|
|
345
383
|
</docgen-index>
|
|
346
384
|
|
|
347
385
|
## API
|
|
386
|
+
|
|
348
387
|
<docgen-api>
|
|
349
388
|
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
350
389
|
|
|
@@ -847,6 +886,132 @@ addListener(eventName: RewardAdPluginEvents.Showed, listenerFunc: () => void) =>
|
|
|
847
886
|
--------------------
|
|
848
887
|
|
|
849
888
|
|
|
889
|
+
### prepareRewardInterstitialAd(...)
|
|
890
|
+
|
|
891
|
+
```typescript
|
|
892
|
+
prepareRewardInterstitialAd(options: RewardInterstitialAdOptions) => Promise<AdLoadInfo>
|
|
893
|
+
```
|
|
894
|
+
|
|
895
|
+
Prepare a reward video ad
|
|
896
|
+
|
|
897
|
+
| Param | Type | Description |
|
|
898
|
+
| ------------- | ----------------------------------------------------------------------------------- | ---------------------------------------------- |
|
|
899
|
+
| **`options`** | <code><a href="#rewardinterstitialadoptions">RewardInterstitialAdOptions</a></code> | <a href="#rewardadoptions">RewardAdOptions</a> |
|
|
900
|
+
|
|
901
|
+
**Returns:** <code>Promise<<a href="#adloadinfo">AdLoadInfo</a>></code>
|
|
902
|
+
|
|
903
|
+
--------------------
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
### showRewardInterstitialAd()
|
|
907
|
+
|
|
908
|
+
```typescript
|
|
909
|
+
showRewardInterstitialAd() => Promise<AdMobRewardInterstitialItem>
|
|
910
|
+
```
|
|
911
|
+
|
|
912
|
+
Show a reward video ad
|
|
913
|
+
|
|
914
|
+
**Returns:** <code>Promise<<a href="#admobrewardinterstitialitem">AdMobRewardInterstitialItem</a>></code>
|
|
915
|
+
|
|
916
|
+
--------------------
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
### addListener(RewardInterstitialAdPluginEvents.FailedToLoad, ...)
|
|
920
|
+
|
|
921
|
+
```typescript
|
|
922
|
+
addListener(eventName: RewardInterstitialAdPluginEvents.FailedToLoad, listenerFunc: (error: AdMobError) => void) => Promise<PluginListenerHandle>
|
|
923
|
+
```
|
|
924
|
+
|
|
925
|
+
| Param | Type |
|
|
926
|
+
| ------------------ | ---------------------------------------------------------------------------------------------------------- |
|
|
927
|
+
| **`eventName`** | <code><a href="#rewardinterstitialadpluginevents">RewardInterstitialAdPluginEvents.FailedToLoad</a></code> |
|
|
928
|
+
| **`listenerFunc`** | <code>(error: <a href="#admoberror">AdMobError</a>) => void</code> |
|
|
929
|
+
|
|
930
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
931
|
+
|
|
932
|
+
--------------------
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
### addListener(RewardInterstitialAdPluginEvents.Loaded, ...)
|
|
936
|
+
|
|
937
|
+
```typescript
|
|
938
|
+
addListener(eventName: RewardInterstitialAdPluginEvents.Loaded, listenerFunc: (info: AdLoadInfo) => void) => Promise<PluginListenerHandle>
|
|
939
|
+
```
|
|
940
|
+
|
|
941
|
+
| Param | Type |
|
|
942
|
+
| ------------------ | ---------------------------------------------------------------------------------------------------- |
|
|
943
|
+
| **`eventName`** | <code><a href="#rewardinterstitialadpluginevents">RewardInterstitialAdPluginEvents.Loaded</a></code> |
|
|
944
|
+
| **`listenerFunc`** | <code>(info: <a href="#adloadinfo">AdLoadInfo</a>) => void</code> |
|
|
945
|
+
|
|
946
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
947
|
+
|
|
948
|
+
--------------------
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
### addListener(RewardInterstitialAdPluginEvents.Rewarded, ...)
|
|
952
|
+
|
|
953
|
+
```typescript
|
|
954
|
+
addListener(eventName: RewardInterstitialAdPluginEvents.Rewarded, listenerFunc: (reward: AdMobRewardInterstitialItem) => void) => Promise<PluginListenerHandle>
|
|
955
|
+
```
|
|
956
|
+
|
|
957
|
+
| Param | Type |
|
|
958
|
+
| ------------------ | -------------------------------------------------------------------------------------------------------- |
|
|
959
|
+
| **`eventName`** | <code><a href="#rewardinterstitialadpluginevents">RewardInterstitialAdPluginEvents.Rewarded</a></code> |
|
|
960
|
+
| **`listenerFunc`** | <code>(reward: <a href="#admobrewardinterstitialitem">AdMobRewardInterstitialItem</a>) => void</code> |
|
|
961
|
+
|
|
962
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
963
|
+
|
|
964
|
+
--------------------
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
### addListener(RewardInterstitialAdPluginEvents.Dismissed, ...)
|
|
968
|
+
|
|
969
|
+
```typescript
|
|
970
|
+
addListener(eventName: RewardInterstitialAdPluginEvents.Dismissed, listenerFunc: () => void) => Promise<PluginListenerHandle>
|
|
971
|
+
```
|
|
972
|
+
|
|
973
|
+
| Param | Type |
|
|
974
|
+
| ------------------ | ------------------------------------------------------------------------------------------------------- |
|
|
975
|
+
| **`eventName`** | <code><a href="#rewardinterstitialadpluginevents">RewardInterstitialAdPluginEvents.Dismissed</a></code> |
|
|
976
|
+
| **`listenerFunc`** | <code>() => void</code> |
|
|
977
|
+
|
|
978
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
979
|
+
|
|
980
|
+
--------------------
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
### addListener(RewardInterstitialAdPluginEvents.FailedToShow, ...)
|
|
984
|
+
|
|
985
|
+
```typescript
|
|
986
|
+
addListener(eventName: RewardInterstitialAdPluginEvents.FailedToShow, listenerFunc: (error: AdMobError) => void) => Promise<PluginListenerHandle>
|
|
987
|
+
```
|
|
988
|
+
|
|
989
|
+
| Param | Type |
|
|
990
|
+
| ------------------ | ---------------------------------------------------------------------------------------------------------- |
|
|
991
|
+
| **`eventName`** | <code><a href="#rewardinterstitialadpluginevents">RewardInterstitialAdPluginEvents.FailedToShow</a></code> |
|
|
992
|
+
| **`listenerFunc`** | <code>(error: <a href="#admoberror">AdMobError</a>) => void</code> |
|
|
993
|
+
|
|
994
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
995
|
+
|
|
996
|
+
--------------------
|
|
997
|
+
|
|
998
|
+
|
|
999
|
+
### addListener(RewardInterstitialAdPluginEvents.Showed, ...)
|
|
1000
|
+
|
|
1001
|
+
```typescript
|
|
1002
|
+
addListener(eventName: RewardInterstitialAdPluginEvents.Showed, listenerFunc: () => void) => Promise<PluginListenerHandle>
|
|
1003
|
+
```
|
|
1004
|
+
|
|
1005
|
+
| Param | Type |
|
|
1006
|
+
| ------------------ | ---------------------------------------------------------------------------------------------------- |
|
|
1007
|
+
| **`eventName`** | <code><a href="#rewardinterstitialadpluginevents">RewardInterstitialAdPluginEvents.Showed</a></code> |
|
|
1008
|
+
| **`listenerFunc`** | <code>() => void</code> |
|
|
1009
|
+
|
|
1010
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
1011
|
+
|
|
1012
|
+
--------------------
|
|
1013
|
+
|
|
1014
|
+
|
|
850
1015
|
### Interfaces
|
|
851
1016
|
|
|
852
1017
|
|
|
@@ -972,6 +1137,24 @@ https://developers.google.com/admob/android/rewarded-video-adapters?hl=en
|
|
|
972
1137
|
| **`amount`** | <code>number</code> | Rewarded amount user got |
|
|
973
1138
|
|
|
974
1139
|
|
|
1140
|
+
#### RewardInterstitialAdOptions
|
|
1141
|
+
|
|
1142
|
+
| Prop | Type | Description |
|
|
1143
|
+
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1144
|
+
| **`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. |
|
|
1145
|
+
|
|
1146
|
+
|
|
1147
|
+
#### AdMobRewardInterstitialItem
|
|
1148
|
+
|
|
1149
|
+
For more information
|
|
1150
|
+
https://developers.google.com/admob/android/rewarded-video-adapters?hl=en
|
|
1151
|
+
|
|
1152
|
+
| Prop | Type | Description |
|
|
1153
|
+
| ------------ | ------------------- | ------------------------ |
|
|
1154
|
+
| **`type`** | <code>string</code> | Rewarded type user got |
|
|
1155
|
+
| **`amount`** | <code>number</code> | Rewarded amount user got |
|
|
1156
|
+
|
|
1157
|
+
|
|
975
1158
|
### Type Aliases
|
|
976
1159
|
|
|
977
1160
|
|
|
@@ -1075,6 +1258,18 @@ From T, pick a set of properties whose keys are in the union K
|
|
|
1075
1258
|
| **`Dismissed`** | <code>'onRewardedVideoAdDismissed'</code> | Emits when the AdReward video is not visible to the user anymore. **Important**: This has nothing to do with the reward it self. This event will emits in this two cases: 1. The user starts the video ad but close it before the reward emit. 2. The user start the video and see it until end, then gets the reward and after that the ad is closed. |
|
|
1076
1259
|
| **`Rewarded`** | <code>'onRewardedVideoAdReward'</code> | Emits when user get rewarded from AdReward |
|
|
1077
1260
|
|
|
1261
|
+
|
|
1262
|
+
#### RewardInterstitialAdPluginEvents
|
|
1263
|
+
|
|
1264
|
+
| Members | Value | Description |
|
|
1265
|
+
| ------------------ | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
1266
|
+
| **`Loaded`** | <code>'onRewardedInterstitialAdLoaded'</code> | Emits after trying to prepare a RewardAd and the Video is loaded and ready to be show |
|
|
1267
|
+
| **`FailedToLoad`** | <code>'onRewardedInterstitialAdFailedToLoad'</code> | Emits after trying to prepare a RewardAd when it could not be loaded |
|
|
1268
|
+
| **`Showed`** | <code>'onRewardedInterstitialAdShowed'</code> | Emits when the AdReward video is visible to the user |
|
|
1269
|
+
| **`FailedToShow`** | <code>'onRewardedInterstitialAdFailedToShow'</code> | Emits when the AdReward video is failed to show |
|
|
1270
|
+
| **`Dismissed`** | <code>'onRewardedInterstitialAdDismissed'</code> | Emits when the AdReward video is not visible to the user anymore. **Important**: This has nothing to do with the reward it self. This event will emits in this two cases: 1. The user starts the video ad but close it before the reward emit. 2. The user start the video and see it until end, then gets the reward and after that the ad is closed. |
|
|
1271
|
+
| **`Rewarded`** | <code>'onRewardedInterstitialAdReward'</code> | Emits when user get rewarded from AdReward |
|
|
1272
|
+
|
|
1078
1273
|
</docgen-api>
|
|
1079
1274
|
|
|
1080
1275
|
## TROUBLE SHOOTING
|
|
@@ -14,6 +14,7 @@ import com.getcapacitor.community.admob.helpers.AuthorizationStatusEnum;
|
|
|
14
14
|
import com.getcapacitor.community.admob.interstitial.AdInterstitialExecutor;
|
|
15
15
|
import com.getcapacitor.community.admob.interstitial.InterstitialAdCallbackAndListeners;
|
|
16
16
|
import com.getcapacitor.community.admob.rewarded.AdRewardExecutor;
|
|
17
|
+
import com.getcapacitor.community.admob.rewardedinterstitial.AdRewardInterstitialExecutor;
|
|
17
18
|
import com.google.android.gms.ads.MobileAds;
|
|
18
19
|
import com.google.android.gms.ads.RequestConfiguration;
|
|
19
20
|
import com.google.android.gms.ads.initialization.InitializationStatus;
|
|
@@ -39,6 +40,12 @@ public class AdMob extends Plugin {
|
|
|
39
40
|
this::notifyListeners,
|
|
40
41
|
getLogTag()
|
|
41
42
|
);
|
|
43
|
+
private final AdRewardInterstitialExecutor adRewardInterstitialExecutor = new AdRewardInterstitialExecutor(
|
|
44
|
+
this::getContext,
|
|
45
|
+
this::getActivity,
|
|
46
|
+
this::notifyListeners,
|
|
47
|
+
getLogTag()
|
|
48
|
+
);
|
|
42
49
|
private final AdInterstitialExecutor adInterstitialExecutor = new AdInterstitialExecutor(
|
|
43
50
|
this::getContext,
|
|
44
51
|
this::getActivity,
|
|
@@ -169,6 +176,16 @@ public class AdMob extends Plugin {
|
|
|
169
176
|
adRewardExecutor.showRewardVideoAd(call, this::notifyListeners);
|
|
170
177
|
}
|
|
171
178
|
|
|
179
|
+
@PluginMethod
|
|
180
|
+
public void prepareRewardInterstitialAd(final PluginCall call) {
|
|
181
|
+
adRewardInterstitialExecutor.prepareRewardInterstitialAd(call, this::notifyListeners);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@PluginMethod
|
|
185
|
+
public void showRewardInterstitialAd(final PluginCall call) {
|
|
186
|
+
adRewardInterstitialExecutor.showRewardInterstitialAd(call, this::notifyListeners);
|
|
187
|
+
}
|
|
188
|
+
|
|
172
189
|
/**
|
|
173
190
|
* @see <a href="https://developers.google.com/admob/android/test-ads#enable_test_devices">Test Devices</a>
|
|
174
191
|
* @see <a href="https://developers.google.com/admob/android/targeting">Target Settings</a>
|
|
@@ -27,6 +27,7 @@ public abstract class AdOptions {
|
|
|
27
27
|
public static final String BANNER_TESTER_ID = "ca-app-pub-3940256099942544/6300978111";
|
|
28
28
|
public static final String INTERSTITIAL_TESTER_ID = "ca-app-pub-3940256099942544/1033173712";
|
|
29
29
|
public static final String REWARD_VIDEO_TESTER_ID = "ca-app-pub-3940256099942544/5224354917";
|
|
30
|
+
public static final String REWARD_INTERSTITIAL_TESTER_ID = "ca-app-pub-3940256099942544/5354046379";
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* The position of the ad, it can be TOP_CENTER,
|
|
@@ -138,6 +139,15 @@ public abstract class AdOptions {
|
|
|
138
139
|
};
|
|
139
140
|
}
|
|
140
141
|
|
|
142
|
+
public AdOptions createRewardInterstitialOptions(PluginCall call) {
|
|
143
|
+
return new AdOptions(call) {
|
|
144
|
+
@Override
|
|
145
|
+
public String getTestingId() {
|
|
146
|
+
return AdOptions.REWARD_INTERSTITIAL_TESTER_ID;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
141
151
|
public AdOptions createGenericOptions(PluginCall call, final String testingID) {
|
|
142
152
|
return new AdOptions(call) {
|
|
143
153
|
@Override
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
package com.getcapacitor.community.admob.rewardedinterstitial;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import androidx.core.util.Supplier;
|
|
6
|
+
import com.getcapacitor.JSObject;
|
|
7
|
+
import com.getcapacitor.PluginCall;
|
|
8
|
+
import com.getcapacitor.PluginMethod;
|
|
9
|
+
import com.getcapacitor.community.admob.helpers.AdViewIdHelper;
|
|
10
|
+
import com.getcapacitor.community.admob.helpers.RequestHelper;
|
|
11
|
+
import com.getcapacitor.community.admob.models.AdMobPluginError;
|
|
12
|
+
import com.getcapacitor.community.admob.models.AdOptions;
|
|
13
|
+
import com.getcapacitor.community.admob.models.Executor;
|
|
14
|
+
import com.google.android.gms.ads.AdRequest;
|
|
15
|
+
import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAd;
|
|
16
|
+
import com.google.android.gms.common.util.BiConsumer;
|
|
17
|
+
|
|
18
|
+
public class AdRewardInterstitialExecutor extends Executor {
|
|
19
|
+
|
|
20
|
+
public static RewardedInterstitialAd mRewardedInterstitialAd;
|
|
21
|
+
|
|
22
|
+
public AdRewardInterstitialExecutor(
|
|
23
|
+
Supplier<Context> contextSupplier,
|
|
24
|
+
Supplier<Activity> activitySupplier,
|
|
25
|
+
BiConsumer<String, JSObject> notifyListenersFunction,
|
|
26
|
+
String pluginLogTag
|
|
27
|
+
) {
|
|
28
|
+
super(contextSupplier, activitySupplier, notifyListenersFunction, pluginLogTag, "AdRewardExecutor");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@PluginMethod
|
|
32
|
+
public void prepareRewardInterstitialAd(final PluginCall call, BiConsumer<String, JSObject> notifyListenersFunction) {
|
|
33
|
+
final AdOptions adOptions = AdOptions.getFactory().createRewardInterstitialOptions(call);
|
|
34
|
+
|
|
35
|
+
activitySupplier
|
|
36
|
+
.get()
|
|
37
|
+
.runOnUiThread(
|
|
38
|
+
() -> {
|
|
39
|
+
try {
|
|
40
|
+
final AdRequest adRequest = RequestHelper.createRequest(adOptions);
|
|
41
|
+
final String id = AdViewIdHelper.getFinalAdId(adOptions, adRequest, logTag, contextSupplier.get());
|
|
42
|
+
RewardedInterstitialAd.load(
|
|
43
|
+
contextSupplier.get(),
|
|
44
|
+
id,
|
|
45
|
+
adRequest,
|
|
46
|
+
RewardedInterstitialAdCallbackAndListeners.INSTANCE.getRewardedAdLoadCallback(
|
|
47
|
+
call,
|
|
48
|
+
notifyListenersFunction,
|
|
49
|
+
adOptions
|
|
50
|
+
)
|
|
51
|
+
);
|
|
52
|
+
} catch (Exception ex) {
|
|
53
|
+
call.reject(ex.getLocalizedMessage(), ex);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@PluginMethod
|
|
60
|
+
public void showRewardInterstitialAd(final PluginCall call, BiConsumer<String, JSObject> notifyListenersFunction) {
|
|
61
|
+
if (mRewardedInterstitialAd == null) {
|
|
62
|
+
String errorMessage = "No Reward Video Ad can be show. It was not prepared or maybe it failed to be prepared.";
|
|
63
|
+
call.reject(errorMessage);
|
|
64
|
+
AdMobPluginError errorObject = new AdMobPluginError(-1, errorMessage);
|
|
65
|
+
notifyListenersFunction.accept(RewardInterstitialAdPluginEvents.FailedToLoad, errorObject);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
activitySupplier
|
|
71
|
+
.get()
|
|
72
|
+
.runOnUiThread(
|
|
73
|
+
() -> {
|
|
74
|
+
mRewardedInterstitialAd.show(
|
|
75
|
+
activitySupplier.get(),
|
|
76
|
+
RewardedInterstitialAdCallbackAndListeners.INSTANCE.getOnUserEarnedRewardListener(call, notifyListenersFunction)
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
} catch (Exception ex) {
|
|
81
|
+
call.reject(ex.getLocalizedMessage(), ex);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.getcapacitor.community.admob.rewardedinterstitial
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.community.admob.models.LoadPluginEventNames
|
|
4
|
+
|
|
5
|
+
object RewardInterstitialAdPluginEvents: LoadPluginEventNames {
|
|
6
|
+
const val Loaded = "onRewardedInterstitialAdLoaded"
|
|
7
|
+
const val FailedToLoad = "onRewardedInterstitialAdFailedToLoad"
|
|
8
|
+
const val Rewarded = "onRewardedInterstitialAdReward"
|
|
9
|
+
override val Showed = "onRewardedInterstitialAdShowed"
|
|
10
|
+
override val FailedToShow = "onRewardedInterstitialAdFailedToShow"
|
|
11
|
+
override val Dismissed = "onRewardedInterstitialAdDismissed"
|
|
12
|
+
}
|