@capacitor-community/admob 7.1.0-1 → 7.2.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.
Files changed (35) hide show
  1. package/CapacitorCommunityAdmob.podspec +1 -1
  2. package/Package.swift +4 -2
  3. package/README.md +415 -376
  4. package/android/build.gradle +15 -14
  5. package/android/src/main/java/com/getcapacitor/community/admob/AdMob.java +5 -0
  6. package/android/src/main/java/com/getcapacitor/community/admob/banner/BannerExecutor.java +17 -14
  7. package/android/src/main/java/com/getcapacitor/community/admob/consent/AdConsentExecutor.java +42 -24
  8. package/android/src/main/java/com/getcapacitor/community/admob/interstitial/AdInterstitialExecutor.java +1 -1
  9. package/android/src/main/java/com/getcapacitor/community/admob/interstitial/InterstitialAdCallbackAndListeners.kt +2 -0
  10. package/android/src/main/java/com/getcapacitor/community/admob/rewarded/AdRewardExecutor.java +1 -1
  11. package/android/src/main/java/com/getcapacitor/community/admob/rewarded/RewardedAdCallbackAndListeners.kt +3 -0
  12. package/android/src/main/java/com/getcapacitor/community/admob/rewardedinterstitial/AdRewardInterstitialExecutor.java +1 -1
  13. package/dist/docs.json +175 -10
  14. package/dist/esm/consent/consent-debug-geography.enum.d.ts +10 -1
  15. package/dist/esm/consent/consent-debug-geography.enum.js +9 -0
  16. package/dist/esm/consent/consent-debug-geography.enum.js.map +1 -1
  17. package/dist/esm/consent/consent-definition.interface.d.ts +7 -0
  18. package/dist/esm/consent/consent-info.interface.d.ts +11 -0
  19. package/dist/esm/consent/privacy-options-requirement-status.enum.d.ts +19 -0
  20. package/dist/esm/consent/privacy-options-requirement-status.enum.js +21 -0
  21. package/dist/esm/consent/privacy-options-requirement-status.enum.js.map +1 -0
  22. package/dist/esm/definitions.d.ts +0 -1
  23. package/dist/esm/definitions.js.map +1 -1
  24. package/dist/esm/shared/ad-options.interface.d.ts +11 -0
  25. package/dist/esm/web.d.ts +1 -0
  26. package/dist/esm/web.js +8 -0
  27. package/dist/esm/web.js.map +1 -1
  28. package/dist/plugin.cjs.js +37 -0
  29. package/dist/plugin.cjs.js.map +1 -1
  30. package/dist/plugin.js +37 -0
  31. package/dist/plugin.js.map +1 -1
  32. package/ios/Sources/AdMobPlugin/AdMobPlugin.swift +7 -0
  33. package/ios/Sources/AdMobPlugin/Banner/BannerExecutor.swift +2 -6
  34. package/ios/Sources/AdMobPlugin/Consent/ConsentExecutor.swift +39 -20
  35. package/package.json +2 -2
package/README.md CHANGED
@@ -1,323 +1,332 @@
1
- <p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" /></p>
2
- <h3 align="center">AdMob</h3>
3
- <p align="center"><strong><code>@capacitor-community/admob</code></strong></p>
4
- <p align="center">
5
- Capacitor community plugin for native AdMob.
6
- </p>
7
-
8
- <p align="center">
9
- <img src="https://img.shields.io/maintenance/yes/2025?style=flat-square" />
10
- <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>
11
- <br>
12
- <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>
13
- <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>
14
- </p>
15
-
16
- ## Maintainers
17
-
18
- | Maintainer | GitHub | Social | Sponsoring Company |
19
- | ------------------- | ------------------------------------------------ | ----------------------------------------------- | ---------------------------------------------- |
20
- | Masahiko Sakakibara | [rdlabo](https://github.com/rdlabo) | [@rdlabo](https://twitter.com/rdlabo) | RELATION DESIGN LABO, GENERAL INC. ASSOCIATION |
21
- | Saninn Salas Diaz | [Saninn Salas Diaz](https://github.com/distante) | [@SaninnSalas](https://twitter.com/SaninnSalas) | |
22
-
23
- Maintenance Status: Actively Maintained
24
-
25
- ## Contributors ✨
26
-
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
-
33
- ## Demo
34
-
35
- [Demo code is here.](https://github.com/capacitor-community/admob/tree/master/demo)
36
-
37
- ### Screenshots
38
-
39
- | | Banner | Interstitial | Reward |
40
- | :---------- | :----------------------------------: | :----------------------------------------: | :----------------------------------: |
41
- | **iOS** | ![](demo/screenshots/ios_banner.png) | ![](demo/screenshots/ios_interstitial.png) | ![](demo/screenshots/ios_reward.png) |
42
- | **Android** | ![](demo/screenshots/md_banner.png) | ![](demo/screenshots/md_interstitial.png) | ![](demo/screenshots/md_reward.png) |
43
-
44
- ## Installation
45
-
46
- If you use capacitor 6:
47
-
48
- ```
49
- % npm install --save @capacitor-community/admob@6
50
- % npx cap update
51
- ```
52
-
53
- ### Android configuration
54
-
55
- In file `android/app/src/main/AndroidManifest.xml`, add the following XML elements under `<manifest><application>` :
56
-
57
- ```xml
58
- <meta-data
59
- android:name="com.google.android.gms.ads.APPLICATION_ID"
60
- android:value="@string/admob_app_id"/>
61
- ```
62
-
63
- In file `android/app/src/main/res/values/strings.xml` add the following lines :
64
-
65
- ```xml
66
- <string name="admob_app_id">[APP_ID]</string>
67
- ```
68
-
69
- Don't forget to replace `[APP_ID]` by your AdMob application Id.
70
-
71
- #### Variables
72
-
73
- This plugin will use the following project variables (defined in your app's `variables.gradle` file):
74
-
75
- - `playServicesAdsVersion` version of `com.google.android.gms:play-services-ads` (default: `23.0.0`)
76
- - `androidxCoreKTXVersion`: version of `androidx.core:core-ktx` (default: `1.13.0`)
77
-
78
- ### iOS configuration
79
-
80
- Add the following in the `ios/App/App/info.plist` file inside of the outermost `<dict>`:
81
-
82
- ```xml
83
- <key>GADIsAdManagerApp</key>
84
- <true/>
85
- <key>GADApplicationIdentifier</key>
86
- <string>[APP_ID]</string>
87
- <key>SKAdNetworkItems</key>
88
- <array>
89
- <dict>
90
- <key>SKAdNetworkIdentifier</key>
91
- <string>cstr6suwn9.skadnetwork</string>
92
- </dict>
93
- </array>
94
- <key>NSUserTrackingUsageDescription</key>
95
- <string>[Why you use NSUserTracking. ex: This identifier will be used to deliver personalized ads to you.]</string>
96
- ```
97
-
98
- Don't forget to replace `[APP_ID]` by your AdMob application Id.
99
-
100
- ## Example
101
-
102
- ### Initialize AdMob
103
-
104
- ```ts
105
- import { AdMob } from '@capacitor-community/admob';
106
-
107
- export async function initialize(): Promise<void> {
108
- await AdMob.initialize();
109
-
110
- const [trackingInfo, consentInfo] = await Promise.all([
111
- AdMob.trackingAuthorizationStatus(),
112
- AdMob.requestConsentInfo(),
113
- ]);
114
-
115
- if (trackingInfo.status === 'notDetermined') {
116
- /**
117
- * If you want to explain TrackingAuthorization before showing the iOS dialog,
118
- * you can show the modal here.
119
- * ex)
120
- * const modal = await this.modalCtrl.create({
121
- * component: RequestTrackingPage,
122
- * });
123
- * await modal.present();
124
- * await modal.onDidDismiss(); // Wait for close modal
125
- **/
126
-
127
- await AdMob.requestTrackingAuthorization();
128
- }
129
-
130
- const authorizationStatus = await AdMob.trackingAuthorizationStatus();
131
- if (
132
- authorizationStatus.status === 'authorized' &&
133
- consentInfo.isConsentFormAvailable &&
134
- consentInfo.status === AdmobConsentStatus.REQUIRED
135
- ) {
136
- await AdMob.showConsentForm();
137
- }
138
- }
139
- ```
140
-
141
- 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
142
-
143
- ### User Message Platform (UMP)
144
-
145
- Later this year, Google will require all publishers serving ads to EEA and UK users to use a Google-certified Consent Management Platform (CMP)
146
-
147
- Currently we just support Google's consent management solution.
148
-
149
- To use UMP, you must [create your GDPR messages](https://support.google.com/admob/answer/10113207?hl=en&ref_topic=10105230&sjid=6731900490614517032-AP)
150
-
151
- You may need to [setup IDFA messages](https://support.google.com/admob/answer/10115027?hl=en), it will work along with GDPR messages and will show when users are not in EEA and UK.
152
-
153
- Example of how to use UMP
154
-
155
- ```ts
156
- import { AdMob, AdmobConsentStatus, AdmobConsentDebugGeography } from '@capacitor-community/admob';
157
-
158
- async showConsent() {
159
- const consentInfo = await AdMob.requestConsentInfo();
160
-
161
- if (consentInfo.isConsentFormAvailable && consentInfo.status === AdmobConsentStatus.REQUIRED) {
162
- const {status} = await AdMob.showConsentForm();
163
- }
164
- }
165
- ```
166
-
167
- 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).
168
-
169
- ```ts
170
- const consentInfo = await AdMob.requestConsentInfo({
171
- debugGeography: AdmobConsentDebugGeography.EEA,
172
- testDeviceIdentifiers: ['YOUR_DEVICE_ID'],
173
- });
174
- ```
175
-
176
- **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.
177
-
178
- **Note**: The order in which they are combined with other methods is as follows.
179
-
180
- 1. AdMob.initialize
181
- 2. AdMob.requestConsentInfo
182
- 3. AdMob.showConsentForm (If consent form required )
183
- 3/ AdMob.showBanner
184
-
185
- ### Show Banner
186
-
187
- ```ts
188
- import {
189
- AdMob,
190
- BannerAdOptions,
191
- BannerAdSize,
192
- BannerAdPosition,
193
- BannerAdPluginEvents,
194
- AdMobBannerSize,
195
- } from '@capacitor-community/admob';
196
-
197
- export async function banner(): Promise<void> {
198
- AdMob.addListener(BannerAdPluginEvents.Loaded, () => {
199
- // Subscribe Banner Event Listener
200
- });
201
-
202
- AdMob.addListener(
203
- BannerAdPluginEvents.SizeChanged,
204
- (size: AdMobBannerSize) => {
205
- // Subscribe Change Banner Size
206
- },
207
- );
208
-
209
- const options: BannerAdOptions = {
210
- adId: 'YOUR ADID',
211
- adSize: BannerAdSize.BANNER,
212
- position: BannerAdPosition.BOTTOM_CENTER,
213
- margin: 0,
214
- // isTesting: true
215
- // npa: true
216
- };
217
- AdMob.showBanner(options);
218
- }
219
- ```
220
-
221
- ### Show Interstitial
222
-
223
- ```ts
224
- import {
225
- AdMob,
226
- AdOptions,
227
- AdLoadInfo,
228
- InterstitialAdPluginEvents,
229
- } from '@capacitor-community/admob';
230
-
231
- export async function interstitial(): Promise<void> {
232
- AdMob.addListener(InterstitialAdPluginEvents.Loaded, (info: AdLoadInfo) => {
233
- // Subscribe prepared interstitial
234
- });
235
-
236
- const options: AdOptions = {
237
- adId: 'YOUR ADID',
238
- // isTesting: true
239
- // npa: true
240
- };
241
- await AdMob.prepareInterstitial(options);
242
- await AdMob.showInterstitial();
243
- }
244
- ```
245
-
246
- ### Show RewardVideo
247
-
248
- ```ts
249
- import {
250
- AdMob,
251
- RewardAdOptions,
252
- AdLoadInfo,
253
- RewardAdPluginEvents,
254
- AdMobRewardItem,
255
- } from '@capacitor-community/admob';
256
-
257
- export async function rewardVideo(): Promise<void> {
258
- AdMob.addListener(RewardAdPluginEvents.Loaded, (info: AdLoadInfo) => {
259
- // Subscribe prepared rewardVideo
260
- });
261
-
262
- AdMob.addListener(
263
- RewardAdPluginEvents.Rewarded,
264
- (rewardItem: AdMobRewardItem) => {
265
- // Subscribe user rewarded
266
- console.log(rewardItem);
267
- },
268
- );
269
-
270
- const options: RewardAdOptions = {
271
- adId: 'YOUR ADID',
272
- // isTesting: true
273
- // npa: true
274
- // ssv: {
275
- // userId: "A user ID to send to your SSV"
276
- // customData: JSON.stringify({ ...MyCustomData })
277
- //}
278
- };
279
- await AdMob.prepareRewardVideoAd(options);
280
- const rewardItem = await AdMob.showRewardVideoAd();
281
- }
282
- ```
283
-
284
- ## Server-side Verification Notice
285
-
286
- SSV callbacks are only fired on Production Adverts, therefore test Ads will not fire off your SSV callback.
287
-
288
- For E2E tests or just for validating the data in your `RewardAdOptions` work as expected, you can add a custom GET
289
- request to your mock endpoint after the `RewardAdPluginEvents.Rewarded` similar to this:
290
-
291
- ```ts
292
- AdMob.addListener(RewardAdPluginEvents.Rewarded, async () => {
293
- // ...
294
- if (ENVIRONMENT_IS_DEVELOPMENT) {
295
- try {
296
- const url =
297
- `https://your-staging-ssv-endpoint` +
298
- new URLSearchParams({
299
- ad_network: 'TEST',
300
- ad_unit: 'TEST',
301
- custom_data: customData, // <-- passed CustomData
302
- reward_amount: 'TEST',
303
- reward_item: 'TEST',
304
- timestamp: 'TEST',
305
- transaction_id: 'TEST',
306
- user_id: userId, // <-- Passed UserID
307
- signature: 'TEST',
308
- key_id: 'TEST',
309
- });
310
- await fetch(url);
311
- } catch (err) {
312
- console.error(err);
313
- }
314
- }
315
- // ...
316
- });
317
- ```
318
-
319
- ## Index
320
-
1
+ <p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" /></p>
2
+ <h3 align="center">AdMob</h3>
3
+ <p align="center"><strong><code>@capacitor-community/admob</code></strong></p>
4
+ <p align="center">
5
+ Capacitor community plugin for native AdMob.
6
+ </p>
7
+
8
+ <p align="center">
9
+ <img src="https://img.shields.io/maintenance/yes/2025?style=flat-square" />
10
+ <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>
11
+ <br>
12
+ <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>
13
+ <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>
14
+ </p>
15
+
16
+ ## Maintainers
17
+
18
+ | Maintainer | GitHub | Social | Sponsoring Company |
19
+ | ------------------- | ------------------------------------------------ | ----------------------------------------------- | ---------------------------------------------- |
20
+ | Masahiko Sakakibara | [rdlabo](https://github.com/rdlabo) | [@rdlabo](https://twitter.com/rdlabo) | RELATION DESIGN LABO, GENERAL INC. ASSOCIATION |
21
+ | Saninn Salas Diaz | [Saninn Salas Diaz](https://github.com/distante) | [@SaninnSalas](https://twitter.com/SaninnSalas) | |
22
+
23
+ Maintenance Status: Actively Maintained
24
+
25
+ ## Contributors ✨
26
+
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
+
33
+ ## Demo
34
+
35
+ [Demo code is here.](https://github.com/capacitor-community/admob/tree/master/demo)
36
+
37
+ ### Screenshots
38
+
39
+ | | Banner | Interstitial | Reward |
40
+ | :---------- | :----------------------------------: | :----------------------------------------: | :----------------------------------: |
41
+ | **iOS** | ![](demo/screenshots/ios_banner.png) | ![](demo/screenshots/ios_interstitial.png) | ![](demo/screenshots/ios_reward.png) |
42
+ | **Android** | ![](demo/screenshots/md_banner.png) | ![](demo/screenshots/md_interstitial.png) | ![](demo/screenshots/md_reward.png) |
43
+
44
+ ## Installation
45
+
46
+ If you use capacitor 6:
47
+
48
+ ```
49
+ % npm install --save @capacitor-community/admob@6
50
+ % npx cap update
51
+ ```
52
+
53
+ ### Android configuration
54
+
55
+ In file `android/app/src/main/AndroidManifest.xml`, add the following XML elements under `<manifest><application>` :
56
+
57
+ ```xml
58
+ <meta-data
59
+ android:name="com.google.android.gms.ads.APPLICATION_ID"
60
+ android:value="@string/admob_app_id"/>
61
+ ```
62
+
63
+ In file `android/app/src/main/res/values/strings.xml` add the following lines :
64
+
65
+ ```xml
66
+ <string name="admob_app_id">[APP_ID]</string>
67
+ ```
68
+
69
+ Don't forget to replace `[APP_ID]` by your AdMob application Id.
70
+
71
+ #### Variables
72
+
73
+ This plugin will use the following project variables (defined in your app's `variables.gradle` file):
74
+
75
+ - `playServicesAdsVersion` version of `com.google.android.gms:play-services-ads` (default: `23.0.0`)
76
+ - `androidxCoreKTXVersion`: version of `androidx.core:core-ktx` (default: `1.13.0`)
77
+
78
+ ### iOS configuration
79
+
80
+ Add the following in the `ios/App/App/info.plist` file inside of the outermost `<dict>`:
81
+
82
+ ```xml
83
+ <key>GADIsAdManagerApp</key>
84
+ <true/>
85
+ <key>GADApplicationIdentifier</key>
86
+ <string>[APP_ID]</string>
87
+ <key>SKAdNetworkItems</key>
88
+ <array>
89
+ <dict>
90
+ <key>SKAdNetworkIdentifier</key>
91
+ <string>cstr6suwn9.skadnetwork</string>
92
+ </dict>
93
+ </array>
94
+ <key>NSUserTrackingUsageDescription</key>
95
+ <string>[Why you use NSUserTracking. ex: This identifier will be used to deliver personalized ads to you.]</string>
96
+ ```
97
+
98
+ Don't forget to replace `[APP_ID]` by your AdMob application Id.
99
+
100
+ ## Example
101
+
102
+ ### Initialize AdMob
103
+
104
+ ```ts
105
+ import { AdMob } from '@capacitor-community/admob';
106
+
107
+ export async function initialize(): Promise<void> {
108
+ await AdMob.initialize();
109
+
110
+ const [trackingInfo, consentInfo] = await Promise.all([
111
+ AdMob.trackingAuthorizationStatus(),
112
+ AdMob.requestConsentInfo(),
113
+ ]);
114
+
115
+ if (trackingInfo.status === 'notDetermined') {
116
+ /**
117
+ * If you want to explain TrackingAuthorization before showing the iOS dialog,
118
+ * you can show the modal here.
119
+ * ex)
120
+ * const modal = await this.modalCtrl.create({
121
+ * component: RequestTrackingPage,
122
+ * });
123
+ * await modal.present();
124
+ * await modal.onDidDismiss(); // Wait for close modal
125
+ **/
126
+
127
+ await AdMob.requestTrackingAuthorization();
128
+ }
129
+
130
+ const authorizationStatus = await AdMob.trackingAuthorizationStatus();
131
+ if (
132
+ authorizationStatus.status === 'authorized' &&
133
+ consentInfo.isConsentFormAvailable &&
134
+ consentInfo.status === AdmobConsentStatus.REQUIRED
135
+ ) {
136
+ await AdMob.showConsentForm();
137
+ }
138
+ }
139
+ ```
140
+
141
+ 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
142
+
143
+ ### User Message Platform (UMP)
144
+
145
+ To use UMP, you must [create your GDPR messages](https://support.google.com/admob/answer/10113207?hl=en&ref_topic=10105230&sjid=6731900490614517032-AP).
146
+
147
+ You may need to [setup IDFA messages](https://support.google.com/admob/answer/10115027?hl=en), it will work along with GDPR messages and will show when users are not in EEA and UK.
148
+
149
+ Example of how to use UMP.
150
+
151
+ ```ts
152
+ import { AdMob } from '@capacitor-community/admob';
153
+
154
+ private canShowAds: boolean | null = null;
155
+
156
+ async showConsent() {
157
+ let consentInfo = await AdMob.requestConsentInfo();
158
+ if (!consentInfo.canRequestAds) {
159
+ consentInfo = await AdMob.showConsentForm();
160
+ this.canShowAds = consentInfo.canRequestAds;
161
+ }
162
+ }
163
+ ```
164
+
165
+ To let users manage their privacy options at any time, show the privacy options form.
166
+ ```ts
167
+ import { AdMob } from '@capacitor-community/admob';
168
+
169
+ showPrivacyOptionsForm() {
170
+ AdMob.showPrivacyOptionsForm();
171
+ }
172
+ ```
173
+
174
+ 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).
175
+
176
+ ```ts
177
+ const consentInfo = await AdMob.requestConsentInfo({
178
+ debugGeography: AdmobConsentDebugGeography.EEA,
179
+ testDeviceIdentifiers: ['YOUR_DEVICE_ID'],
180
+ });
181
+ ```
182
+
183
+ **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.
184
+
185
+ **Note**: The order in which they are combined with other methods is as follows.
186
+
187
+ 1. AdMob.initialize
188
+ 2. AdMob.requestConsentInfo
189
+ 3. AdMob.showConsentForm (If consent form required )
190
+ 3/ AdMob.showBanner
191
+
192
+ ### Show Banner
193
+
194
+ ```ts
195
+ import {
196
+ AdMob,
197
+ BannerAdOptions,
198
+ BannerAdSize,
199
+ BannerAdPosition,
200
+ BannerAdPluginEvents,
201
+ AdMobBannerSize,
202
+ } from '@capacitor-community/admob';
203
+
204
+ export async function banner(): Promise<void> {
205
+ AdMob.addListener(BannerAdPluginEvents.Loaded, () => {
206
+ // Subscribe Banner Event Listener
207
+ });
208
+
209
+ AdMob.addListener(
210
+ BannerAdPluginEvents.SizeChanged,
211
+ (size: AdMobBannerSize) => {
212
+ // Subscribe Change Banner Size
213
+ },
214
+ );
215
+
216
+ const options: BannerAdOptions = {
217
+ adId: 'YOUR ADID',
218
+ adSize: BannerAdSize.BANNER,
219
+ position: BannerAdPosition.BOTTOM_CENTER,
220
+ margin: 0,
221
+ // isTesting: true
222
+ // npa: true
223
+ };
224
+ AdMob.showBanner(options);
225
+ }
226
+ ```
227
+
228
+ ### Show Interstitial
229
+
230
+ ```ts
231
+ import {
232
+ AdMob,
233
+ AdOptions,
234
+ AdLoadInfo,
235
+ InterstitialAdPluginEvents,
236
+ } from '@capacitor-community/admob';
237
+
238
+ export async function interstitial(): Promise<void> {
239
+ AdMob.addListener(InterstitialAdPluginEvents.Loaded, (info: AdLoadInfo) => {
240
+ // Subscribe prepared interstitial
241
+ });
242
+
243
+ const options: AdOptions = {
244
+ adId: 'YOUR ADID',
245
+ // isTesting: true
246
+ // npa: true
247
+ // immersiveMode: true
248
+ };
249
+ await AdMob.prepareInterstitial(options);
250
+ await AdMob.showInterstitial();
251
+ }
252
+ ```
253
+
254
+ ### Show RewardVideo
255
+
256
+ ```ts
257
+ import {
258
+ AdMob,
259
+ RewardAdOptions,
260
+ AdLoadInfo,
261
+ RewardAdPluginEvents,
262
+ AdMobRewardItem,
263
+ } from '@capacitor-community/admob';
264
+
265
+ export async function rewardVideo(): Promise<void> {
266
+ AdMob.addListener(RewardAdPluginEvents.Loaded, (info: AdLoadInfo) => {
267
+ // Subscribe prepared rewardVideo
268
+ });
269
+
270
+ AdMob.addListener(
271
+ RewardAdPluginEvents.Rewarded,
272
+ (rewardItem: AdMobRewardItem) => {
273
+ // Subscribe user rewarded
274
+ console.log(rewardItem);
275
+ },
276
+ );
277
+
278
+ const options: RewardAdOptions = {
279
+ adId: 'YOUR ADID',
280
+ // isTesting: true
281
+ // npa: true
282
+ // immersiveMode: true
283
+ // ssv: {
284
+ // userId: "A user ID to send to your SSV"
285
+ // customData: JSON.stringify({ ...MyCustomData })
286
+ //}
287
+ };
288
+ await AdMob.prepareRewardVideoAd(options);
289
+ const rewardItem = await AdMob.showRewardVideoAd();
290
+ }
291
+ ```
292
+
293
+ ## Server-side Verification Notice
294
+
295
+ SSV callbacks are only fired on Production Adverts, therefore test Ads will not fire off your SSV callback.
296
+
297
+ For E2E tests or just for validating the data in your `RewardAdOptions` work as expected, you can add a custom GET
298
+ request to your mock endpoint after the `RewardAdPluginEvents.Rewarded` similar to this:
299
+
300
+ ```ts
301
+ AdMob.addListener(RewardAdPluginEvents.Rewarded, async () => {
302
+ // ...
303
+ if (ENVIRONMENT_IS_DEVELOPMENT) {
304
+ try {
305
+ const url =
306
+ `https://your-staging-ssv-endpoint` +
307
+ new URLSearchParams({
308
+ ad_network: 'TEST',
309
+ ad_unit: 'TEST',
310
+ custom_data: customData, // <-- passed CustomData
311
+ reward_amount: 'TEST',
312
+ reward_item: 'TEST',
313
+ timestamp: 'TEST',
314
+ transaction_id: 'TEST',
315
+ user_id: userId, // <-- Passed UserID
316
+ signature: 'TEST',
317
+ key_id: 'TEST',
318
+ });
319
+ await fetch(url);
320
+ } catch (err) {
321
+ console.error(err);
322
+ }
323
+ }
324
+ // ...
325
+ });
326
+ ```
327
+
328
+ ## Index
329
+
321
330
  <docgen-index>
322
331
 
323
332
  * [`initialize(...)`](#initialize)
@@ -336,6 +345,7 @@ AdMob.addListener(RewardAdPluginEvents.Rewarded, async () => {
336
345
  * [`addListener(BannerAdPluginEvents.Closed, ...)`](#addlistenerbanneradplugineventsclosed-)
337
346
  * [`addListener(BannerAdPluginEvents.AdImpression, ...)`](#addlistenerbanneradplugineventsadimpression-)
338
347
  * [`requestConsentInfo(...)`](#requestconsentinfo)
348
+ * [`showPrivacyOptionsForm()`](#showprivacyoptionsform)
339
349
  * [`showConsentForm()`](#showconsentform)
340
350
  * [`resetConsentInfo()`](#resetconsentinfo)
341
351
  * [`prepareInterstitial(...)`](#prepareinterstitial)
@@ -365,10 +375,10 @@ AdMob.addListener(RewardAdPluginEvents.Rewarded, async () => {
365
375
  * [Type Aliases](#type-aliases)
366
376
  * [Enums](#enums)
367
377
 
368
- </docgen-index>
369
-
370
- ## API
371
-
378
+ </docgen-index>
379
+
380
+ ## API
381
+
372
382
  <docgen-api>
373
383
  <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
374
384
 
@@ -411,7 +421,6 @@ requestTrackingAuthorization() => Promise<void>
411
421
  ```
412
422
 
413
423
  request requestTrackingAuthorization (iOS &gt;14).
414
- This is deprecated method. We recommend UMP Consent.
415
424
 
416
425
  **Since:** 5.2.0
417
426
 
@@ -645,6 +654,19 @@ Request user consent information
645
654
  --------------------
646
655
 
647
656
 
657
+ ### showPrivacyOptionsForm()
658
+
659
+ ```typescript
660
+ showPrivacyOptionsForm() => Promise<void>
661
+ ```
662
+
663
+ Shows a google privacy options form (rendered from your GDPR message config).
664
+
665
+ **Since:** 7.0.3
666
+
667
+ --------------------
668
+
669
+
648
670
  ### showConsentForm()
649
671
 
650
672
  ```typescript
@@ -1084,14 +1106,15 @@ addListener(eventName: RewardInterstitialAdPluginEvents.Showed, listenerFunc: ()
1084
1106
 
1085
1107
  This interface extends <a href="#adoptions">AdOptions</a>
1086
1108
 
1087
- | Prop | Type | Description | Default | Since |
1088
- | --------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | ----- |
1089
- | **`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 | <code>ADAPTIVE_BANNER</code> | 3.0.0 |
1090
- | **`position`** | <code><a href="#banneradposition">BannerAdPosition</a></code> | Set Banner Ad position. TOP_CENTER or CENTER or BOTTOM_CENTER | <code>TOP_CENTER</code> | 1.1.2 |
1091
- | **`adId`** | <code>string</code> | The ad unit ID that you want to request | | 1.1.2 |
1092
- | **`isTesting`** | <code>boolean</code> | You can use test mode of ad. | <code>false</code> | 1.1.2 |
1093
- | **`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. | <code>0</code> | 1.1.2 |
1094
- | **`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 | <code>false</code> | 1.2.0 |
1109
+ | Prop | Type | Description | Default | Since |
1110
+ | ------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | ----- |
1111
+ | **`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 | <code>ADAPTIVE_BANNER</code> | 3.0.0 |
1112
+ | **`position`** | <code><a href="#banneradposition">BannerAdPosition</a></code> | Set Banner Ad position. TOP_CENTER or CENTER or BOTTOM_CENTER | <code>TOP_CENTER</code> | 1.1.2 |
1113
+ | **`adId`** | <code>string</code> | The ad unit ID that you want to request | | 1.1.2 |
1114
+ | **`isTesting`** | <code>boolean</code> | You can use test mode of ad. | <code>false</code> | 1.1.2 |
1115
+ | **`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. | <code>0</code> | 1.1.2 |
1116
+ | **`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 | <code>false</code> | 1.2.0 |
1117
+ | **`immersiveMode`** | <code>boolean</code> | Sets a flag that controls if this interstitial or reward object will be displayed in immersive mode. Call this method before show. During show, if this flag is on and immersive mode is supported, SYSTEM_UI_FLAG_IMMERSIVE_STICKY &SYSTEM_UI_FLAG_HIDE_NAVIGATION will be turned on for interstitial or reward ad. | | 7.0.3 |
1095
1118
 
1096
1119
 
1097
1120
  #### PluginListenerHandle
@@ -1124,10 +1147,12 @@ https://developers.google.com/android/reference/com/google/android/gms/ads/AdErr
1124
1147
 
1125
1148
  #### AdmobConsentInfo
1126
1149
 
1127
- | Prop | Type | Description | Since |
1128
- | ---------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------- | ----- |
1129
- | **`status`** | <code><a href="#admobconsentstatus">AdmobConsentStatus</a></code> | The consent status of the user. | 5.0.0 |
1130
- | **`isConsentFormAvailable`** | <code>boolean</code> | If `true` a consent form is available and vice versa. | 5.0.0 |
1150
+ | Prop | Type | Description | Since |
1151
+ | ------------------------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------- | ----- |
1152
+ | **`status`** | <code><a href="#admobconsentstatus">AdmobConsentStatus</a></code> | The consent status of the user. | 5.0.0 |
1153
+ | **`isConsentFormAvailable`** | <code>boolean</code> | If `true` a consent form is available and vice versa. | 5.0.0 |
1154
+ | **`canRequestAds`** | <code>boolean</code> | If `true` an ad can be shown. | 7.0.3 |
1155
+ | **`privacyOptionsRequirementStatus`** | <code><a href="#privacyoptionsrequirementstatus">PrivacyOptionsRequirementStatus</a></code> | Privacy options requirement status of the user. | 7.0.3 |
1131
1156
 
1132
1157
 
1133
1158
  #### AdmobConsentRequestOptions
@@ -1148,23 +1173,25 @@ https://developers.google.com/android/reference/com/google/android/gms/ads/AdErr
1148
1173
 
1149
1174
  #### AdOptions
1150
1175
 
1151
- | Prop | Type | Description | Default | Since |
1152
- | --------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ----- |
1153
- | **`adId`** | <code>string</code> | The ad unit ID that you want to request | | 1.1.2 |
1154
- | **`isTesting`** | <code>boolean</code> | You can use test mode of ad. | <code>false</code> | 1.1.2 |
1155
- | **`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. | <code>0</code> | 1.1.2 |
1156
- | **`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 | <code>false</code> | 1.2.0 |
1176
+ | Prop | Type | Description | Default | Since |
1177
+ | ------------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ----- |
1178
+ | **`adId`** | <code>string</code> | The ad unit ID that you want to request | | 1.1.2 |
1179
+ | **`isTesting`** | <code>boolean</code> | You can use test mode of ad. | <code>false</code> | 1.1.2 |
1180
+ | **`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. | <code>0</code> | 1.1.2 |
1181
+ | **`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 | <code>false</code> | 1.2.0 |
1182
+ | **`immersiveMode`** | <code>boolean</code> | Sets a flag that controls if this interstitial or reward object will be displayed in immersive mode. Call this method before show. During show, if this flag is on and immersive mode is supported, SYSTEM_UI_FLAG_IMMERSIVE_STICKY &SYSTEM_UI_FLAG_HIDE_NAVIGATION will be turned on for interstitial or reward ad. | | 7.0.3 |
1157
1183
 
1158
1184
 
1159
1185
  #### RewardAdOptions
1160
1186
 
1161
- | Prop | Type | Description | Default | Since |
1162
- | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ----- |
1163
- | **`ssv`** | <code><a href="#atleastone">AtLeastOne</a>&lt;{ /** * 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; }&gt;</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. | | |
1164
- | **`adId`** | <code>string</code> | The ad unit ID that you want to request | | 1.1.2 |
1165
- | **`isTesting`** | <code>boolean</code> | You can use test mode of ad. | <code>false</code> | 1.1.2 |
1166
- | **`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. | <code>0</code> | 1.1.2 |
1167
- | **`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 | <code>false</code> | 1.2.0 |
1187
+ | Prop | Type | Description | Default | Since |
1188
+ | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ----- |
1189
+ | **`ssv`** | <code><a href="#atleastone">AtLeastOne</a>&lt;{ /** * 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; }&gt;</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. | | |
1190
+ | **`adId`** | <code>string</code> | The ad unit ID that you want to request | | 1.1.2 |
1191
+ | **`isTesting`** | <code>boolean</code> | You can use test mode of ad. | <code>false</code> | 1.1.2 |
1192
+ | **`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. | <code>0</code> | 1.1.2 |
1193
+ | **`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 | <code>false</code> | 1.2.0 |
1194
+ | **`immersiveMode`** | <code>boolean</code> | Sets a flag that controls if this interstitial or reward object will be displayed in immersive mode. Call this method before show. During show, if this flag is on and immersive mode is supported, SYSTEM_UI_FLAG_IMMERSIVE_STICKY &SYSTEM_UI_FLAG_HIDE_NAVIGATION will be turned on for interstitial or reward ad. | | 7.0.3 |
1168
1195
 
1169
1196
 
1170
1197
  #### AdMobRewardItem
@@ -1180,13 +1207,14 @@ https://developers.google.com/admob/android/rewarded-video-adapters?hl=en
1180
1207
 
1181
1208
  #### RewardInterstitialAdOptions
1182
1209
 
1183
- | Prop | Type | Description | Default | Since |
1184
- | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ----- |
1185
- | **`ssv`** | <code><a href="#atleastone">AtLeastOne</a>&lt;{ /** * 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; }&gt;</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. | | |
1186
- | **`adId`** | <code>string</code> | The ad unit ID that you want to request | | 1.1.2 |
1187
- | **`isTesting`** | <code>boolean</code> | You can use test mode of ad. | <code>false</code> | 1.1.2 |
1188
- | **`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. | <code>0</code> | 1.1.2 |
1189
- | **`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 | <code>false</code> | 1.2.0 |
1210
+ | Prop | Type | Description | Default | Since |
1211
+ | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ----- |
1212
+ | **`ssv`** | <code><a href="#atleastone">AtLeastOne</a>&lt;{ /** * 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; }&gt;</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. | | |
1213
+ | **`adId`** | <code>string</code> | The ad unit ID that you want to request | | 1.1.2 |
1214
+ | **`isTesting`** | <code>boolean</code> | You can use test mode of ad. | <code>false</code> | 1.1.2 |
1215
+ | **`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. | <code>0</code> | 1.1.2 |
1216
+ | **`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 | <code>false</code> | 1.2.0 |
1217
+ | **`immersiveMode`** | <code>boolean</code> | Sets a flag that controls if this interstitial or reward object will be displayed in immersive mode. Call this method before show. During show, if this flag is on and immersive mode is supported, SYSTEM_UI_FLAG_IMMERSIVE_STICKY &SYSTEM_UI_FLAG_HIDE_NAVIGATION will be turned on for interstitial or reward ad. | | 7.0.3 |
1190
1218
 
1191
1219
 
1192
1220
  #### AdMobRewardInterstitialItem
@@ -1272,13 +1300,24 @@ From T, pick a set of properties whose keys are in the union K
1272
1300
  | **`UNKNOWN`** | <code>'UNKNOWN'</code> | Unknown consent status, AdsConsent.requestInfoUpdate needs to be called to update it. |
1273
1301
 
1274
1302
 
1303
+ #### PrivacyOptionsRequirementStatus
1304
+
1305
+ | Members | Value | Description |
1306
+ | ------------------ | --------------------------- | ---------------------------------------------- |
1307
+ | **`NOT_REQUIRED`** | <code>'NOT_REQUIRED'</code> | Privacy options entry point is not required. |
1308
+ | **`REQUIRED`** | <code>'REQUIRED'</code> | Privacy options entry point is required. |
1309
+ | **`UNKNOWN`** | <code>'UNKNOWN'</code> | Privacy options requirement status is unknown. |
1310
+
1311
+
1275
1312
  #### AdmobConsentDebugGeography
1276
1313
 
1277
- | Members | Value | Description |
1278
- | -------------- | -------------- | -------------------------------------------------- |
1279
- | **`DISABLED`** | <code>0</code> | Debug geography disabled. |
1280
- | **`EEA`** | <code>1</code> | Geography appears as in EEA for debug devices. |
1281
- | **`NOT_EEA`** | <code>2</code> | Geography appears as not in EEA for debug devices. |
1314
+ | Members | Value | Description |
1315
+ | -------------- | -------------- | ------------------------------------------------------------- |
1316
+ | **`DISABLED`** | <code>0</code> | Debug geography disabled. |
1317
+ | **`EEA`** | <code>1</code> | Geography appears as in EEA for debug devices. |
1318
+ | **`NOT_EEA`** | <code>2</code> | Geography appears as not in EEA for debug devices. |
1319
+ | **`US`** | <code>3</code> | Geography appears as in regulated US state for debug devices. |
1320
+ | **`OTHER`** | <code>4</code> | Geography appears as OTHER state for debug devices. |
1282
1321
 
1283
1322
 
1284
1323
  #### InterstitialAdPluginEvents
@@ -1315,17 +1354,17 @@ From T, pick a set of properties whose keys are in the union K
1315
1354
  | **`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. |
1316
1355
  | **`Rewarded`** | <code>'onRewardedInterstitialAdReward'</code> | Emits when user get rewarded from AdReward |
1317
1356
 
1318
- </docgen-api>
1319
-
1320
- ## TROUBLE SHOOTING
1321
-
1322
- ### If you have error:
1323
-
1324
- > [error] Error running update: Analyzing dependencies
1325
- > [!] CocoaPods could not find compatible versions for pod "Google-Mobile-Ads-SDK":
1326
-
1327
- You should run `pod repo update` ;
1328
-
1329
- ## License
1330
-
1331
- Capacitor AdMob is [MIT licensed](./LICENSE).
1357
+ </docgen-api>
1358
+
1359
+ ## TROUBLE SHOOTING
1360
+
1361
+ ### If you have error:
1362
+
1363
+ > [error] Error running update: Analyzing dependencies
1364
+ > [!] CocoaPods could not find compatible versions for pod "Google-Mobile-Ads-SDK":
1365
+
1366
+ You should run `pod repo update` ;
1367
+
1368
+ ## License
1369
+
1370
+ Capacitor AdMob is [MIT licensed](./LICENSE).