-
Notifications
You must be signed in to change notification settings - Fork 91
feat: support for App Open Ad en Android e iOS #386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e3c2d24
ded6452
d1bbba1
9494d2e
e65274f
8d6d787
a1d73cf
2549a0a
8f33ad7
4aac09b
23ab476
eee34de
5359b16
3548d4f
a00d292
f81c2d6
a0eae03
b82471b
f742340
a885fad
3b9d047
5b3f914
ed1c654
5fcb155
88caf87
ef80ce7
9d8c31b
7c8c244
416edc0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,4 @@ | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| <p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" /></p> | ||||||||||||||||||||||||||||||
| <h3 align="center">AdMob</h3> | ||||||||||||||||||||||||||||||
| <p align="center"><strong><code>@capacitor-community/admob</code></strong></p> | ||||||||||||||||||||||||||||||
|
|
@@ -188,7 +189,46 @@ const consentInfo = await AdMob.requestConsentInfo({ | |||||||||||||||||||||||||||||
| 2. AdMob.requestConsentInfo | ||||||||||||||||||||||||||||||
| 3. AdMob.showConsentForm (If consent form required ) | ||||||||||||||||||||||||||||||
| 3/ AdMob.showBanner | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ### Show App Open Ad | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ```ts | ||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||
| AdMob, | ||||||||||||||||||||||||||||||
| AppOpenAdPluginEvents, | ||||||||||||||||||||||||||||||
| AppOpenAdOptions, | ||||||||||||||||||||||||||||||
| } from '@capacitor-community/admob'; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| export async function showAppOpenAd(): Promise<void> { | ||||||||||||||||||||||||||||||
| // listen to events | ||||||||||||||||||||||||||||||
| AdMob.addListener(AppOpenAdPluginEvents.Loaded, () => { | ||||||||||||||||||||||||||||||
| console.log('App Open Ad loaded'); | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
| AdMob.addListener(AppOpenAdPluginEvents.FailedToLoad, () => { | ||||||||||||||||||||||||||||||
| console.log('Failed to load App Open Ad'); | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
| AdMob.addListener(AppOpenAdPluginEvents.Opened, () => { | ||||||||||||||||||||||||||||||
| console.log('App Open Ad open'); | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
| AdMob.addListener(AppOpenAdPluginEvents.Closed, () => { | ||||||||||||||||||||||||||||||
| console.log('App Open Ad close'); | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
| AdMob.addListener(AppOpenAdPluginEvents.FailedToShow, () => { | ||||||||||||||||||||||||||||||
| console.log('Failed to load App Open Ad'); | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const options: AppOpenAdOptions = { | ||||||||||||||||||||||||||||||
| adUnitId: 'TU_AD_UNIT_ID', | ||||||||||||||||||||||||||||||
| showOnColdStart: true, // Opcional | ||||||||||||||||||||||||||||||
| showOnForeground: true, // Opcional | ||||||||||||||||||||||||||||||
|
BETOXL marked this conversation as resolved.
Comment on lines
+217
to
+223
|
||||||||||||||||||||||||||||||
| console.log('Failed to load App Open Ad'); | |
| }); | |
| const options: AppOpenAdOptions = { | |
| adUnitId: 'TU_AD_UNIT_ID', | |
| showOnColdStart: true, // Opcional | |
| showOnForeground: true, // Opcional | |
| console.log('Failed to show App Open Ad'); | |
| }); | |
| const options: AppOpenAdOptions = { | |
| adUnitId: 'YOUR_AD_UNIT_ID', | |
| showOnColdStart: true, // Optional | |
| showOnForeground: true, // Optional |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,21 +8,27 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.getcapacitor.PluginMethod; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.getcapacitor.annotation.CapacitorPlugin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.getcapacitor.annotation.Permission; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.getcapacitor.community.admob.banner.BannerExecutor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.getcapacitor.community.admob.consent.AdConsentExecutor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.getcapacitor.community.admob.helpers.AuthorizationStatusEnum; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.getcapacitor.community.admob.interstitial.AdInterstitialExecutor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.getcapacitor.community.admob.interstitial.InterstitialAdCallbackAndListeners; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.getcapacitor.community.admob.rewarded.AdRewardExecutor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.getcapacitor.community.admob.rewardedinterstitial.AdRewardInterstitialExecutor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.getcapacitor.community.admob.appopen.AppOpenAdPlugin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.google.android.gms.ads.MobileAds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.google.android.gms.ads.RequestConfiguration; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.google.android.gms.ads.initialization.InitializationStatus; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.google.android.gms.ads.initialization.OnInitializationCompleteListener; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.json.JSONException; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @CapacitorPlugin( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| permissions = { @Permission(alias = "network", strings = { Manifest.permission.ACCESS_NETWORK_STATE, Manifest.permission.INTERNET }) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| permissions = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Permission(alias = "network", strings = { Manifest.permission.ACCESS_NETWORK_STATE, Manifest.permission.INTERNET }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public class AdMob extends Plugin { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -34,18 +40,21 @@ public class AdMob extends Plugin { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this::notifyListeners, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getLogTag() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private final AdRewardExecutor adRewardExecutor = new AdRewardExecutor( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this::getContext, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this::getActivity, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this::notifyListeners, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getLogTag() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private final AdRewardInterstitialExecutor adRewardInterstitialExecutor = new AdRewardInterstitialExecutor( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this::getContext, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this::getActivity, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this::notifyListeners, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getLogTag() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private final AdInterstitialExecutor adInterstitialExecutor = new AdInterstitialExecutor( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this::getContext, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this::getActivity, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -61,7 +70,27 @@ public class AdMob extends Plugin { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getLogTag() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Initialize AdMob with appId | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private final AppOpenAdPlugin appOpenAdPlugin = new AppOpenAdPlugin(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @PluginMethod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public void loadAppOpen(final PluginCall call) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| appOpenAdPlugin.loadAppOpen(call); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @PluginMethod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public void showAppOpen(final PluginCall call) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| appOpenAdPlugin.showAppOpen(call); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @PluginMethod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public void isAppOpenLoaded(final PluginCall call) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+73
to
+86
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private final AppOpenAdPlugin appOpenAdPlugin = new AppOpenAdPlugin(); | |
| @PluginMethod | |
| public void loadAppOpen(final PluginCall call) { | |
| appOpenAdPlugin.loadAppOpen(call); | |
| } | |
| @PluginMethod | |
| public void showAppOpen(final PluginCall call) { | |
| appOpenAdPlugin.showAppOpen(call); | |
| } | |
| @PluginMethod | |
| public void isAppOpenLoaded(final PluginCall call) { | |
| private AppOpenAdPlugin getAppOpenAdPlugin() { | |
| if (getBridge() == null) { | |
| return null; | |
| } | |
| try { | |
| Plugin plugin = getBridge().getPlugin("AppOpenAdPlugin"); | |
| if (plugin instanceof AppOpenAdPlugin) { | |
| return (AppOpenAdPlugin) plugin; | |
| } | |
| } catch (Exception ignored) { | |
| // If the plugin cannot be obtained, return null and let callers handle it. | |
| } | |
| return null; | |
| } | |
| @PluginMethod | |
| public void loadAppOpen(final PluginCall call) { | |
| AppOpenAdPlugin appOpenAdPlugin = getAppOpenAdPlugin(); | |
| if (appOpenAdPlugin == null) { | |
| call.reject("AppOpenAdPlugin is not available"); | |
| return; | |
| } | |
| appOpenAdPlugin.loadAppOpen(call); | |
| } | |
| @PluginMethod | |
| public void showAppOpen(final PluginCall call) { | |
| AppOpenAdPlugin appOpenAdPlugin = getAppOpenAdPlugin(); | |
| if (appOpenAdPlugin == null) { | |
| call.reject("AppOpenAdPlugin is not available"); | |
| return; | |
| } | |
| appOpenAdPlugin.showAppOpen(call); | |
| } | |
| @PluginMethod | |
| public void isAppOpenLoaded(final PluginCall call) { | |
| AppOpenAdPlugin appOpenAdPlugin = getAppOpenAdPlugin(); | |
| if (appOpenAdPlugin == null) { | |
| call.reject("AppOpenAdPlugin is not available"); | |
| return; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep the documentation link for future developers
Uh oh!
There was an error while loading. Please reload this page.