@capacitor-community/admob 8.2.0 → 8.2.1-beta.pr490.shaf4a3cab095f4
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/Package.swift +1 -1
- package/README.md +8 -7
- package/android/build.gradle +5 -1
- package/android/src/main/java/com/getcapacitor/community/admob/AdMob.java +88 -0
- package/android/src/main/java/com/getcapacitor/community/admob/nativeads/NativeAdExecutor.kt +626 -0
- package/android/src/main/java/com/getcapacitor/community/admob/nativeads/NativeAdFeedSessions.kt +35 -0
- package/android/src/main/java/com/getcapacitor/community/admob/nativeads/NativeAdPlacementValue.kt +44 -0
- package/android/src/main/java/com/getcapacitor/community/admob/nativeads/NativeAdPluginEvents.kt +11 -0
- package/android/src/main/java/com/getcapacitor/community/admob/nativeads/PluginNativeAdView.kt +187 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/native-ads/index.d.ts +6 -0
- package/dist/esm/native-ads/index.js +4 -0
- package/dist/esm/native-ads/index.js.map +1 -0
- package/dist/esm/native-ads/native-ad-definitions.interface.d.ts +20 -0
- package/dist/esm/native-ads/native-ad-definitions.interface.js +2 -0
- package/dist/esm/native-ads/native-ad-definitions.interface.js.map +1 -0
- package/dist/esm/native-ads/native-ad-element.d.ts +9 -0
- package/dist/esm/native-ads/native-ad-element.js +53 -0
- package/dist/esm/native-ads/native-ad-element.js.map +1 -0
- package/dist/esm/native-ads/native-ad-event.interface.d.ts +5 -0
- package/dist/esm/native-ads/native-ad-event.interface.js +2 -0
- package/dist/esm/native-ads/native-ad-event.interface.js.map +1 -0
- package/dist/esm/native-ads/native-ad-feed.d.ts +72 -0
- package/dist/esm/native-ads/native-ad-feed.js +643 -0
- package/dist/esm/native-ads/native-ad-feed.js.map +1 -0
- package/dist/esm/native-ads/native-ad-geometry.d.ts +8 -0
- package/dist/esm/native-ads/native-ad-geometry.js +92 -0
- package/dist/esm/native-ads/native-ad-geometry.js.map +1 -0
- package/dist/esm/native-ads/native-ad-options.interface.d.ts +40 -0
- package/dist/esm/native-ads/native-ad-options.interface.js +2 -0
- package/dist/esm/native-ads/native-ad-options.interface.js.map +1 -0
- package/dist/esm/native-ads/native-ad-placement.interface.d.ts +28 -0
- package/dist/esm/native-ads/native-ad-placement.interface.js +2 -0
- package/dist/esm/native-ads/native-ad-placement.interface.js.map +1 -0
- package/dist/esm/native-ads/native-ad-plugin-events.enum.d.ts +9 -0
- package/dist/esm/native-ads/native-ad-plugin-events.enum.js +11 -0
- package/dist/esm/native-ads/native-ad-plugin-events.enum.js.map +1 -0
- package/dist/esm/native-ads/native-ad-style.interface.d.ts +30 -0
- package/dist/esm/native-ads/native-ad-style.interface.js +2 -0
- package/dist/esm/native-ads/native-ad-style.interface.js.map +1 -0
- package/dist/esm/native-ads/native-ad-template.enum.d.ts +11 -0
- package/dist/esm/native-ads/native-ad-template.enum.js +13 -0
- package/dist/esm/native-ads/native-ad-template.enum.js.map +1 -0
- package/dist/esm/web.d.ts +9 -1
- package/dist/esm/web.js +15 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +883 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +883 -1
- package/dist/plugin.js.map +1 -1
- package/docs/configuration.md +2 -2
- package/docs/consent.md +6 -6
- package/docs/events.md +3 -2
- package/docs/migration.md +22 -2
- package/docs/native-ads.md +187 -0
- package/docs/rewarded.md +13 -0
- package/ios/Sources/AdMobPlugin/AdMobPlugin.swift +103 -41
- package/ios/Sources/AdMobPlugin/AppOpen/AppOpenAdPluginEvents.swift +3 -0
- package/ios/Sources/AdMobPlugin/Banner/BannerAdPluginEvents.swift +3 -0
- package/ios/Sources/AdMobPlugin/Banner/BannerAdSizeEnum.swift +3 -0
- package/ios/Sources/AdMobPlugin/Banner/BannerExecutor.swift +4 -4
- package/ios/Sources/AdMobPlugin/Helper/AuthorizationStatusEnum.swift +3 -0
- package/ios/Sources/AdMobPlugin/Interstitial/AdInterstitialExecutor.swift +3 -0
- package/ios/Sources/AdMobPlugin/Interstitial/InterstitialAdPluginEvents.swift +3 -0
- package/ios/Sources/AdMobPlugin/NativeAds/NativeAdExecutor.swift +354 -0
- package/ios/Sources/AdMobPlugin/NativeAds/NativeAdFeedSessions.swift +34 -0
- package/ios/Sources/AdMobPlugin/NativeAds/NativeAdPlacementValue.swift +50 -0
- package/ios/Sources/AdMobPlugin/NativeAds/NativeAdPluginEvents.swift +11 -0
- package/ios/Sources/AdMobPlugin/NativeAds/NativeAdScrollTracker.swift +66 -0
- package/ios/Sources/AdMobPlugin/NativeAds/NativeAdValues.swift +27 -0
- package/ios/Sources/AdMobPlugin/NativeAds/PluginNativeAdView.swift +187 -0
- package/ios/Sources/AdMobPlugin/Rewarded/AdRewardExecutor.swift +3 -0
- package/ios/Sources/AdMobPlugin/Rewarded/RewardAdPluginEvents.swift +3 -0
- package/ios/Sources/AdMobPlugin/RewardedInterstitial/AdRewardInterstitialExecutor.swift +3 -0
- package/ios/Sources/AdMobPlugin/RewardedInterstitial/RewardInterstitialAdPluginEvents.swift +3 -0
- package/ios/Tests/AdMobPluginTests/AdMobPluginTests.swift +82 -10
- package/ios/Tests/AdMobPluginTests/NativeAdScrollTrackerTests.swift +47 -0
- package/package.json +6 -4
|
@@ -15,6 +15,6 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
s.swift_version = '5.1'
|
|
16
16
|
s.static_framework = true
|
|
17
17
|
s.dependency 'Capacitor'
|
|
18
|
-
s.dependency 'Google-Mobile-Ads-SDK', '13.
|
|
18
|
+
s.dependency 'Google-Mobile-Ads-SDK', '13.11.0'
|
|
19
19
|
s.dependency 'GoogleUserMessagingPlatform', '~> 3.1'
|
|
20
20
|
end
|
package/Package.swift
CHANGED
|
@@ -11,7 +11,7 @@ let package = Package(
|
|
|
11
11
|
],
|
|
12
12
|
dependencies: [
|
|
13
13
|
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0"),
|
|
14
|
-
.package(url: "https://github.com/googleads/swift-package-manager-google-mobile-ads.git", exact: "13.
|
|
14
|
+
.package(url: "https://github.com/googleads/swift-package-manager-google-mobile-ads.git", exact: "13.11.0"),
|
|
15
15
|
.package(url: "https://github.com/googleads/swift-package-manager-google-user-messaging-platform.git", .upToNextMinor(from: "3.1.0"))
|
|
16
16
|
],
|
|
17
17
|
targets: [
|
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ Capacitor community plugin for native AdMob. This plugin wraps the Google Mobile
|
|
|
56
56
|
|
|
57
57
|
This plugin already ships Google Mobile Ads SDK. Install the package, then add your AdMob **application** ID in AndroidManifest / Info.plist. Google's Get started guides for [Android](https://developers.google.com/admob/android/quick-start) and [iOS](https://developers.google.com/admob/ios/quick-start) explain app IDs and SKAdNetwork identifiers (Apple's ad conversion IDs); do not add a second Mobile Ads dependency.
|
|
58
58
|
|
|
59
|
-
This plugin targets `@capacitor-community/admob` **v8** and Capacitor 8.5 or later (within v8). It supports iOS 15 or later and Android API 24 or later.
|
|
59
|
+
This plugin targets `@capacitor-community/admob` **v8.2.0** and Capacitor 8.5 or later (within v8). It supports iOS 15 or later and Android API 24 or later.
|
|
60
60
|
|
|
61
61
|
```bash
|
|
62
62
|
npm install @capacitor-community/admob
|
|
@@ -67,7 +67,7 @@ If you still use Capacitor 7, install `@capacitor-community/admob@7`.
|
|
|
67
67
|
|
|
68
68
|
### Google Mobile Ads SDK versions
|
|
69
69
|
|
|
70
|
-
This major version pins Google Mobile Ads SDK **25.4.x** on Android and **13.
|
|
70
|
+
This major version pins Google Mobile Ads SDK **25.4.x** on Android and **13.11.0** on iOS (Swift Package Manager and CocoaPods). Leave those versions unless you have a specific need. Google's [Next-Gen SDK for Android](https://developers.google.com/admob/android/next-gen) waits until the next plugin major. See [Migration](https://docs.rdlabo.dev/projects/capacitor-admob/docs/migration) for the policy behind the pins.
|
|
71
71
|
|
|
72
72
|
### Android configuration
|
|
73
73
|
|
|
@@ -134,7 +134,7 @@ Run `pod repo update` in `ios/`, then `npx cap sync ios` again.
|
|
|
134
134
|
|
|
135
135
|
## First test banner
|
|
136
136
|
|
|
137
|
-
After installation and platform setup, initialize the SDK
|
|
137
|
+
After installation and platform setup, request consent, initialize the SDK when ads may be requested, and show a Google demo banner. Use the platform banner IDs from [Testing](https://docs.rdlabo.dev/projects/capacitor-admob/docs/testing)—do not create your own ad unit for this first check.
|
|
138
138
|
|
|
139
139
|
Call `startAdMob` from a user action or after the UI is ready (for example a button or post-navigation hook), not only at module evaluation time.
|
|
140
140
|
|
|
@@ -148,8 +148,6 @@ const bannerAdId =
|
|
|
148
148
|
: 'ca-app-pub-3940256099942544/6300978111';
|
|
149
149
|
|
|
150
150
|
async function startAdMob() {
|
|
151
|
-
await AdMob.initialize();
|
|
152
|
-
|
|
153
151
|
let consentInfo = await AdMob.requestConsentInfo();
|
|
154
152
|
if (consentInfo.isConsentFormAvailable && consentInfo.status === AdmobConsentStatus.REQUIRED) {
|
|
155
153
|
consentInfo = await AdMob.showConsentForm();
|
|
@@ -160,6 +158,8 @@ async function startAdMob() {
|
|
|
160
158
|
return;
|
|
161
159
|
}
|
|
162
160
|
|
|
161
|
+
await AdMob.initialize();
|
|
162
|
+
|
|
163
163
|
const options: BannerAdOptions = {
|
|
164
164
|
adId: bannerAdId,
|
|
165
165
|
adSize: BannerAdSize.ADAPTIVE_BANNER,
|
|
@@ -184,18 +184,19 @@ Expected result: when `canRequestAds` is true, a Google test banner appears at t
|
|
|
184
184
|
|
|
185
185
|
## Documentation
|
|
186
186
|
|
|
187
|
-
Start with [Installation](#installation) above, then [Configuration](https://docs.rdlabo.dev/projects/capacitor-admob/docs/configuration) and [Consent](https://docs.rdlabo.dev/projects/capacitor-admob/docs/consent). Run the first test banner, then use [Testing](https://docs.rdlabo.dev/projects/capacitor-admob/docs/testing) for demo units and devices. Pick an ad format from the table above. The same guides are also on the [documentation site](https://docs.rdlabo.dev/projects/capacitor-admob) (English and Japanese). If you opened this README on npm, use that site for the guides — the `docs/` files
|
|
187
|
+
Start with [Installation](#installation) above, then [Configuration](https://docs.rdlabo.dev/projects/capacitor-admob/docs/configuration) and [Consent](https://docs.rdlabo.dev/projects/capacitor-admob/docs/consent). Run the first test banner, then use [Testing](https://docs.rdlabo.dev/projects/capacitor-admob/docs/testing) for demo units and devices. Pick an ad format from the table above. The same guides are also on the [documentation site](https://docs.rdlabo.dev/projects/capacitor-admob) (English and Japanese). If you opened this README on npm, use that site for the guides — the `docs/` files are also included in the package. Method signatures are in the API section below.
|
|
188
188
|
|
|
189
189
|
- [Configuration](https://docs.rdlabo.dev/projects/capacitor-admob/docs/configuration) — `AdMob.initialize` and SDK options.
|
|
190
190
|
- [Consent](https://docs.rdlabo.dev/projects/capacitor-admob/docs/consent) — privacy consent and iOS tracking authorization.
|
|
191
191
|
- [Testing](https://docs.rdlabo.dev/projects/capacitor-admob/docs/testing) — demo ad units, test devices, and consent testing.
|
|
192
192
|
- [Banner Ads](https://docs.rdlabo.dev/projects/capacitor-admob/docs/banner) — banner options, lifecycle, and events.
|
|
193
|
+
- [Native Ads](./docs/native-ads.md) — feed placement, styling, lifecycle, and events.
|
|
193
194
|
- Full-screen ads:
|
|
194
195
|
- [Interstitial Ads](https://docs.rdlabo.dev/projects/capacitor-admob/docs/interstitial) — load, show, and multiple prepared ads.
|
|
195
196
|
- [Rewarded Ads](https://docs.rdlabo.dev/projects/capacitor-admob/docs/rewarded) — rewarded video, rewarded interstitial, and server-side verification.
|
|
196
197
|
- [App Open Ads](https://docs.rdlabo.dev/projects/capacitor-admob/docs/app-open) — load and present on foreground transitions.
|
|
197
198
|
- [Ad Events](https://docs.rdlabo.dev/projects/capacitor-admob/docs/events) — shared lifecycle events, errors, and revenue data.
|
|
198
|
-
- [Migration Guide](https://docs.rdlabo.dev/projects/capacitor-admob/docs/migration) —
|
|
199
|
+
- [Migration Guide](https://docs.rdlabo.dev/projects/capacitor-admob/docs/migration) — upgrade steps and behavior changes in v8.2.0 and earlier versions.
|
|
199
200
|
|
|
200
201
|
<!-- rdlabo-docs-omit -->
|
|
201
202
|
## Index
|
package/android/build.gradle
CHANGED
|
@@ -53,14 +53,18 @@ android {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
repositories {
|
|
56
|
+
if (project.hasProperty('nativeUIEngineRepository')) {
|
|
57
|
+
maven { url = uri(project.property('nativeUIEngineRepository')) }
|
|
58
|
+
}
|
|
56
59
|
google()
|
|
57
|
-
|
|
60
|
+
mavenCentral()
|
|
58
61
|
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
def testRunner = "1.7.0"
|
|
62
65
|
|
|
63
66
|
dependencies {
|
|
67
|
+
implementation "io.github.webview-native-ui:engine:${project.findProperty('nativeUIEngineVersion') ?: '1.0.0'}"
|
|
64
68
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
65
69
|
implementation project(':capacitor-android')
|
|
66
70
|
|
|
@@ -17,6 +17,7 @@ import com.getcapacitor.community.admob.consent.AdConsentExecutor;
|
|
|
17
17
|
import com.getcapacitor.community.admob.helpers.AuthorizationStatusEnum;
|
|
18
18
|
import com.getcapacitor.community.admob.interstitial.AdInterstitialExecutor;
|
|
19
19
|
import com.getcapacitor.community.admob.interstitial.InterstitialAdCallbackAndListeners;
|
|
20
|
+
import com.getcapacitor.community.admob.nativeads.NativeAdExecutor;
|
|
20
21
|
import com.getcapacitor.community.admob.rewarded.AdRewardExecutor;
|
|
21
22
|
import com.getcapacitor.community.admob.rewardedinterstitial.AdRewardInterstitialExecutor;
|
|
22
23
|
import com.google.android.gms.ads.MobileAds;
|
|
@@ -70,6 +71,44 @@ public class AdMob extends Plugin {
|
|
|
70
71
|
|
|
71
72
|
private final AppOpenAdPlugin appOpenAdPlugin = new AppOpenAdPlugin();
|
|
72
73
|
|
|
74
|
+
private final NativeAdExecutor nativeAdExecutor = new NativeAdExecutor(
|
|
75
|
+
this::getContext,
|
|
76
|
+
this::getActivity,
|
|
77
|
+
() -> getBridge().getWebView(),
|
|
78
|
+
this::notifyListeners,
|
|
79
|
+
getLogTag()
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
private boolean nativeAdPlacementChannelRegistered;
|
|
83
|
+
|
|
84
|
+
@Override
|
|
85
|
+
public void load() {
|
|
86
|
+
super.load();
|
|
87
|
+
try {
|
|
88
|
+
io.github.webview_native_ui.engine.NativeUIProjection.install(getBridge().getWebView());
|
|
89
|
+
} catch (Exception error) {
|
|
90
|
+
android.util.Log.w(getLogTag(), "Native UI channel unavailable; retaining native tracking", error);
|
|
91
|
+
}
|
|
92
|
+
if (
|
|
93
|
+
androidx.webkit.WebViewFeature.isFeatureSupported(androidx.webkit.WebViewFeature.WEB_MESSAGE_LISTENER) &&
|
|
94
|
+
!getBridge().getConfig().isUsingLegacyBridge()
|
|
95
|
+
) {
|
|
96
|
+
try {
|
|
97
|
+
androidx.webkit.WebViewCompat.addWebMessageListener(
|
|
98
|
+
getBridge().getWebView(),
|
|
99
|
+
"capacitorAdMobPlacements",
|
|
100
|
+
getBridge().getAllowedOriginRules(),
|
|
101
|
+
(view, message, origin, mainFrame, reply) -> {
|
|
102
|
+
if (mainFrame) nativeAdExecutor.updateDirectPlacements(message.getData());
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
nativeAdPlacementChannelRegistered = true;
|
|
106
|
+
} catch (RuntimeException ignored) {
|
|
107
|
+
// Placement updates retain the regular Capacitor bridge as a fallback.
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
73
112
|
@PluginMethod
|
|
74
113
|
public void loadAppOpen(final PluginCall call) {
|
|
75
114
|
appOpenAdPlugin.loadAppOpen(getContext(), getActivity(), call, this::notifyListeners);
|
|
@@ -213,6 +252,45 @@ public class AdMob extends Plugin {
|
|
|
213
252
|
bannerExecutor.removeBanner(call);
|
|
214
253
|
}
|
|
215
254
|
|
|
255
|
+
// ---------------------------------------------------------
|
|
256
|
+
// NATIVE ADS
|
|
257
|
+
// ---------------------------------------------------------
|
|
258
|
+
|
|
259
|
+
@PluginMethod
|
|
260
|
+
public void startNativeAdFeed(final PluginCall call) {
|
|
261
|
+
nativeAdExecutor.startFeed(call);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
@PluginMethod
|
|
265
|
+
public void destroyNativeAdFeed(final PluginCall call) {
|
|
266
|
+
nativeAdExecutor.destroyFeed(call);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
@PluginMethod
|
|
270
|
+
public void loadNativeAd(final PluginCall call) {
|
|
271
|
+
nativeAdExecutor.load(call);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
@PluginMethod
|
|
275
|
+
public void updateNativeAdPlacements(final PluginCall call) {
|
|
276
|
+
nativeAdExecutor.updatePlacements(call);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
@PluginMethod
|
|
280
|
+
public void removeNativeAd(final PluginCall call) {
|
|
281
|
+
nativeAdExecutor.remove(call);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
@PluginMethod
|
|
285
|
+
public void captureNativeAdSnapshot(final PluginCall call) {
|
|
286
|
+
nativeAdExecutor.captureSnapshot(call);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
@PluginMethod
|
|
290
|
+
public void prepareNativeAdSnapshot(final PluginCall call) {
|
|
291
|
+
nativeAdExecutor.prepareSnapshot(call);
|
|
292
|
+
}
|
|
293
|
+
|
|
216
294
|
// ---------------------------------------------------------
|
|
217
295
|
// INTERSTITIAL ADS
|
|
218
296
|
// ---------------------------------------------------------
|
|
@@ -319,4 +397,14 @@ public class AdMob extends Plugin {
|
|
|
319
397
|
call.reject(error.toString());
|
|
320
398
|
}
|
|
321
399
|
}
|
|
400
|
+
|
|
401
|
+
@Override
|
|
402
|
+
protected void handleOnDestroy() {
|
|
403
|
+
if (nativeAdPlacementChannelRegistered) {
|
|
404
|
+
androidx.webkit.WebViewCompat.removeWebMessageListener(getBridge().getWebView(), "capacitorAdMobPlacements");
|
|
405
|
+
nativeAdPlacementChannelRegistered = false;
|
|
406
|
+
}
|
|
407
|
+
nativeAdExecutor.destroyAll();
|
|
408
|
+
super.handleOnDestroy();
|
|
409
|
+
}
|
|
322
410
|
}
|