capacitor-community / admob Goto Github PK
View Code? Open in Web Editor NEWCommunity plugin for using Google AdMob
License: MIT License
Community plugin for using Google AdMob
License: MIT License
Hello,
My IOS app is working fine when I add the isTesting = true
, Ads show up with 'Test mode' label, but when I remove the isTesting flag and install the app on IOS, nothing shows up. Is this normal? I even distributed the app via firebase distribute and it is the same behavior. As far as I know, my AdMob setting is correct and I do not see any error to indicate that there is something going wrong. My app has not been published in the apple store yet so Not sure if this has to do with it.
@capacitor-community/admob (1.0.1)
Xcode 11.6 (11E708)
Project Format Xcode 8.0-compatible
phonegap-version cli-6.2.0
iOS Build Target v11.0
iOS Simulator iPhone 11 v13.6
iOS iPhone 11 v13.4.1
Ads show in the simulator on iOS, but on the actual device nothing would show if the iOS preference Limit Ad Tracking was turned on. A post on Stack Overflow suggested adding the following to NSAppTransportSecurity:
NSAllowsArbitraryLoadsInWebContent <true>
NSAllowsArbitraryLoadsForMedia <true>
And that makes the Ads show, but then the Apple docs here https://developer.apple.com/documentation/bundleresources/information_property_list/nsapptransportsecurity/nsallowsarbitraryloads make it clear that's (a) not a good idea, and (b) Apps may face rejection if the justification isn't good enough.
As I understand it, AdMob should be loading over https anyway, so not entirely sure why adding those keys to NSAppTransportSecurity worked.
Is there a bug in the plugin or should I be looking elsewhere for the cause of the problem?
Could you please add a sample when you use Ionic5 with Vue3?
Describe the bug
I received a crashlytics error in production.
The error was the following:
Fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'void com.google.android.gms.ads.AdView.pause()' on a null object reference
To Reproduce
It's actually hard to reproduce as this is just a crash which was reported by crashlytics.
Expected behavior
The app should not crash ๐
Smartphone (please complete the following information):
Additional context
I just wanted to make sure, that every step is taken to prevent that error. It should not be the case, that the app crashes after calling pause.
Describe the bug
In my Ionic app the ad is overlapping the content. It's the same behavior like I had in another capacitor admob plugin which was fixed. Here's the issue
I noticed that @rahadur is a contributor to this plugin. Maybe he can quickly fix it like before.
To Reproduce
Steps to reproduce the behavior:
position: AdPosition.BOTTOM_CENTER
optionThanks and all the best.
Describe the bug
The ads render by admob are by default personalized ads, if we want to send non personalized ads (for example in a country protected by GDPR where the user does not want to be tracked) we have to send the npa
. See https://developers.google.com/admob/android/eu-consent#forward-consent
Currently there is not way to send any extra option to the Builder so all the ads served are tracked personalized ads.
See: ionic-team/capacitor#3634
In that way, updates/changes to the typescript interfaces are automatically documented ๐
Describe the bug
The content is covered by the banner and also scrolling the text it's not possible to read the last part.
The problem was reproduced with this demo(https://github.com/capacitor-community/admob/tree/master/demo/angular) on the iPhone 11
Smartphone (please complete the following information):
On integration of Interstitial, autoShow option gives error:
'autoShow' does not exist in type 'AdOptions'
const optionsInter: AdOptions = {
adId: InterplatformAdId,
isTesting: true,
autoShow: true
}
I cannot build the project. I am getting cannot resolve symbol 'community' error.
Dependencies
"dependencies": {
"@angular/common": "^9.1.12",
"@angular/core": "^9.1.12",
"@angular/forms": "^9.1.12",
"@angular/platform-browser": "^9.1.12",
"@angular/platform-browser-dynamic": "^9.1.12",
"@angular/router": "^9.1.12",
"@capacitor-community/admob": "^1.0.1",
"@capacitor/android": "^2.3.0",
"@capacitor/core": "2.2.1",
"@fortawesome/angular-fontawesome": "^0.6.1",
"@fortawesome/fontawesome-svg-core": "^1.2.30",
"@fortawesome/free-brands-svg-icons": "^5.14.0",
"@fortawesome/free-regular-svg-icons": "^5.14.0",
"@fortawesome/free-solid-svg-icons": "^5.14.0",
"@ionic-native/core": "^5.0.7",
"@ionic-native/native-storage": "^5.27.0",
"@ionic-native/splash-screen": "^5.0.0",
"@ionic-native/status-bar": "^5.0.0",
"@ionic/angular": "^5.0.0",
"@ionic/storage": "^2.2.0",
"@rdlabo/capacitor-admob": "^1.0.4",
"cordova-android": "8.1.0",
"cordova-plugin-androidx": "^2.0.0",
"cordova-plugin-nativestorage": "^2.3.2",
"cordova-sqlite-storage": "^5.0.0",
"howler": "^2.2.0",
"ionic-admob": "^0.19.9",
"moment": "^2.27.0",
"rxjs": "~6.5.1",
"rxjs-compat": "^6.6.0",
"rxjs-observable": "0.0.7",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.901.11",
"@angular/cli": "9.1.10",
"@angular/compiler": "^9.1.12",
"@angular/compiler-cli": "^9.1.12",
"@angular/language-service": "^9.1.12",
"@capacitor/cli": "2.2.1",
"@ionic/angular-toolkit": "^2.1.1",
"@ionic/lab": "3.1.7",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.12.50",
"codelyzer": "^5.1.2",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-ionic-webview": "^4.2.1",
"cordova-plugin-splashscreen": "^5.0.4",
"cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-whitelist": "^1.3.4",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~3.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "~5.4.3",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~3.8.3"
},
I am getting an error like below on android build.
Execution failed for task ':capacitor-android:processDebugGoogleServices'.
> No matching client found for package name 'com.getcapacitor.android'
Also log cat screen error
java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException:
My AndroidManifest.xml file like this
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="test">
<application
.... other codes
<meta-data
android:value="ca-app-pub-xxx~xxxx"
android:name="com.google.android.gms.ads.APPLICATION_ID" />
</application>
</manifest>
My strings.xml file like this
<?xml version='1.0' encoding='utf-8'?>
<resources>
<string name="app_name">test</string>
<string name="title_activity_main">test</string>
<string name="package_name">test</string>
<string name="custom_url_scheme">test</string>
<string name="admob_app_id">ca-app-pub-xxx~xxxx</string>
</resources>
And MainActivity.java
package test;
import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;
import java.util.ArrayList;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
add(com.getcapacitor.community.admob.AdMob.class);
}});
}
}
Everything looks fine for the code side but I am getting an error anyway. How can I resolve this problem.
Describe the bug
The plugin uses the Admob-SDK with version >= 7.64.0.
Google released version 8.0.0 which has some breaking changes. For example, the class GADInterstitialDelegate
doesn't exist anymore.
Expected behavior
The iOS build should work
I searched the repository about the version of the google mobile ads sdk, but i didn't find anything.
What is the version of the Google Sdk that we are using? If it is lower than 7.55.0 iOS application will have a problem.
As indicated recently by google, Apple will no longer accept applications (updates or new) that are using UIWebView to serve their ads.
We will no longer be able to
The first version of google-mobile-ads-sdk that only uses WKWebview to serve the ads is 7.55.0 as indicated here.
Hello ฤฑ have a problem for banner size when ฤฑ open app on large size phone ,banner closing tab menu https://prnt.sc/x7gsu6
I use adSize: AdSize.SMART_BANNER,
I give margin for tab menu<ion-tab-bar slot="bottom" style="margin-bottom: 42px;">
Should I use Adsize.CUSTOMto fix this? how is it used?
*Is there anyone who can help?
Describe the bug
I'm getting many crashes reported by Firebase Crashlytics caused by some messaging dependency (com.google.firebase.iid.zzbe and com.getcapacitor.CapacitorFirebaseMessagingService) .
To Reproduce
I was not able to reproduce it consistently. The error happened more frequent in production.
Expected behavior
While I can handle some crashes here and there due to huge ecosystem Android has, I've had a very small number Crash-Free users on Android, 64%.
Screenshots
Link to gallery
SS 1
SS 2
SS 3
SS 4
Desktop (please complete the following information):
N/A
Smartphone (please complete the following information):
Android devices. No pattern has been found in terms of OS Versions
Additional context
I'm also using some other capacitor-community plugins that may have some impact (@capacitor-community/admob, @capacitor-community/firebase-analytics, @capacitor-community/firebase-crashlytics, @capacitor-community/firebase-remote-config, @capacitor-community/media). I'll attach the complete plugin list below:
ionic info
Ionic:
Ionic CLI : 6.12.0
Ionic Framework : @ionic/angular 5.3.4
@angular-devkit/build-angular : 0.901.12
@angular-devkit/schematics : 9.1.12
@angular/cli : 9.1.12
@ionic/angular-toolkit : 2.3.3
Capacitor:
Capacitor CLI : 2.4.2
@capacitor/core : 2.4.2
Utility:
cordova-res : not installed
native-run (update available: 1.2.1) : 1.0.0
System:
NodeJS : v14.6.0
npm : 6.14.8
OS : macOS Catalina
package.json
"dependencies": {
"@angular/common": "^9.1.12",
"@angular/core": "^9.1.12",
"@angular/forms": "^9.1.12",
"@angular/platform-browser": "^9.1.12",
"@angular/platform-browser-dynamic": "^9.1.12",
"@angular/router": "^9.1.12",
"@capacitor-community/admob": "^1.2.0-0",
"@capacitor-community/firebase-analytics": "^0.2.0",
"@capacitor-community/firebase-crashlytics": "^0.3.0",
"@capacitor-community/firebase-remote-config": "^0.1.3",
"@capacitor-community/media": "^1.0.1",
"@capacitor/android": "^2.4.0",
"@capacitor/core": "^2.4.0",
"@capacitor/ios": "^2.4.0",
"@ionic-native/core": "^5.28.0",
"@ionic-super-tabs/angular": "^7.0.8",
"@ionic/angular": "^5.3.2",
"@ionic/storage": "^2.3.0",
"@ngx-translate/core": "^12.1.2",
"@ngx-translate/http-loader": "^4.0.0",
"cordova-sqlite-storage": "^5.0.1",
"ngx-countup": "^7.3.3",
"rxjs": "~6.5.1",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.901.12",
"@angular/cli": "^9.1.12",
"@angular/compiler": "^9.1.12",
"@angular/compiler-cli": "^9.1.12",
"@angular/language-service": "^9.1.12",
"@capacitor/cli": "^2.4.0",
"@ionic/angular-toolkit": "^2.3.3",
"@types/jasmine": "^3.5.14",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.12.54",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^5.2.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~3.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"ts-node": "~8.3.0",
"tslint": "^6.1.3",
"typescript": "~3.8.3"
}
Describe the bug
A clear and concise description of what the bug is.
In version 1.2.6, actually since this commit: eb3b91d, top or bottom banner don't work anymore
To Reproduce
Steps to reproduce the behavior:
Currently on Android (I do not know if also in iOS) showBanner
just react to the first call and ignores the other ones letting the Banner update it self.
@PluginMethod
public void showBanner(final PluginCall call) {
if (mAdView != null) {
return;
}
...
A Use case for this is the following:
mAdView
is instantited)Error receiving when invoking banner ad and app crashing.
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.ViewGroup.addView(android.view.View)' on a null object reference
at com.getcapacitor.community.admob.executors.BannerExecutor.lambda$createNewAdView$4$BannerExecutor(BannerExecutor.java:236)
at com.getcapacitor.community.admob.executors.-$$Lambda$BannerExecutor$0eAbza0hC4NXMOrCT0oZXRSNZnY.run(lambda)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
Any thoughts on this?
I Am getting and Error { "errorCode": 3 }
in onAdFailedToLoad
eventListener
I don't know what it means, nor there is any documentation for this
When setting isTesting
option to true
, the Ad is loading successfully
https://support.google.com/admob/answer/9997589?hl=ja
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Using in Ionic 5.
Everything is working fine but I am getting below exceptions whenever I am trying to Resume and Hide banners.
2020-09-21 15:31:26.465 17046-17335/com.xxx.xxx.app E/Capacitor/Plugin: getAdSize must be called on the main UI thread. java.lang.IllegalStateException: getAdSize must be called on the main UI thread. at mt.a(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:6) at com.google.android.gms.ads.nonagon.shim.h.ao(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:1) at com.google.android.gms.ads.nonagon.shim.i.ao(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:0) at com.google.android.gms.ads.internal.client.av.a(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:54) at fx.onTransact(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:4) at android.os.Binder.transact(Binder.java:925) at com.google.android.gms.internal.ads.zzgi.transactAndReadException(com.google.android.gms:play-services-ads-base@@19.1.0:10) at com.google.android.gms.internal.ads.zzwb.zzkg(com.google.android.gms:play-services-ads-lite@@19.1.0:46) at com.google.android.gms.internal.ads.zzxv.getAdSize(com.google.android.gms:play-services-ads-lite@@19.1.0:62) at com.google.android.gms.ads.BaseAdView.getAdSize(com.google.android.gms:play-services-ads-lite@@19.1.0:13) at com.google.android.gms.ads.AdView.getAdSize(com.google.android.gms:play-services-ads-lite@@19.1.0:22) at com.getcapacitor.community.admob.AdMob.resumeBanner(AdMob.java:242) at java.lang.reflect.Method.invoke(Native Method) at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99) at com.getcapacitor.Bridge$1.run(Bridge.java:521) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.os.HandlerThread.run(HandlerThread.java:67) 2020-09-21 15:31:26.465 17046-17335/com.xxxx.xxx.app D/Capacitor: Sending plugin error: {"save":false,"callbackId":"130052663","pluginId":"AdMob","methodName":"resumeBanner","success":false,"error":{"message":"getAdSize must be called on the main UI thread."}} 2020-09-21 15:31:26.492 17046-17046/com.xxx.xxx.app D/Capacitor/AdMob: Banner AD Resumed
Unfortunately, requestTrackingAuthorization does not generate the dialog shown here: https://twitter.com/rdlabo/status/1301392984026394628. I tried in simulator as well as on real device with the latest version @capacitor-community/admob v1.2.5. Tried to submit the app but Apple rejects because no dialog is created, see screenshot: https://i.imgur.com/Vfa1is0.png
Any suggestions on how to generate the dialog? Is it even expected to be created when testing the app on device?
Describe the bug
Getting multiple crashes on beta testers using Android. They report the crash happens just before an interstitial video plays.
Google Play Console gives me the following info on the crashes:
java.lang.IllegalStateException
com.getcapacitor.community.admob.AdMob$7$1.run
java.lang.IllegalStateException: at com.google.android.gms.internal.ads.zzxx.zzcp(com.google.android.gms:play-services-ads-lite@@19.1.0:163)
at com.google.android.gms.internal.ads.zzxx.show(com.google.android.gms:play-services-ads-lite@@19.1.0:142)
at com.google.android.gms.ads.InterstitialAd.show(com.google.android.gms:play-services-ads-lite@@19.1.0:20)
at com.getcapacitor.community.admob.AdMob$7$1.run (AdMob.java:362)
at android.app.Activity.runOnUiThread (Activity.java:6904)
at com.getcapacitor.community.admob.AdMob$7.run (AdMob.java:359)
at android.os.Handler.handleCallback (Handler.java:883)
at android.os.Handler.dispatchMessage (Handler.java:100)
at android.os.Looper.loop (Looper.java:359)
at android.app.ActivityThread.main (ActivityThread.java:7418)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:935)
Smartphone (please complete the following information):
OS
Android 11 (SDK 30)
Android 10 (SDK 29)
Devices
Google Pixel 5
Samsung Galaxy S20
Sony Xperia XZ2
** Other Info **
Here's how I'm initialising and then displaying the interstitial:
The initAds function is called during login:
function initAds(){
Capacitor.Plugins.AdMob.initialize();
var admobid = {};
if(capacitorDevice.operatingSystem == 'ios') {
admobid = {
interstitial: 'xxxxx'
};
} else {
admobid = {
interstitial: 'xxxxx'
};
}
admobInterstitialOptions = {
adId: admobid.interstitial,
autoShow: false,
}
Capacitor.Plugins.AdMob.prepareInterstitial(admobInterstitialOptions);
}
Then this code has a 1 in 10 random chance of displaying the interstitial and preparing the next one:
$(document).on('tab:show', '.tab', function(page) {
if(Math.floor(Math.random() * 10)<1) {
Capacitor.Plugins.AdMob.showInterstitial();
Capacitor.Plugins.AdMob.prepareInterstitial(admobInterstitialOptions);
}
});
Anyone else seen this, or know what I'm doing wrong?
Describe the bug
When doing the test directly from the android studio it works fine, the admob is initializing very good.
But when we are doing the build from the ionic capacitor cmd and use the generated apk , that is where the white screen happening upon the initialization of the app.
Within the initialization below using ionic 5 with admob latest version
export class AppComponent {
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar,
private dataService: DataService
) {
// Initialize AdMob for your Application
AdMob.initialize();
this.initializeApp();
}
To Reproduce
The bug is occuring upon the initialization of the app
Expected behavior
it should proceed to mainscreen
Screenshots
error response from the android studio
2020-11-10 12:42:59.711 25142-25142/? E/Capacitor/Console: File: http://localhost/vendor-es2015.js - Line 44076 - Msg: ERROR TypeError: Cannot read property 'initialize' of undefined
2020-11-10 12:42:59.724 25142-25142/? W/Capacitor/Console: File: http://localhost/vendor-es2015.js - Line 109555 - Msg: Native: tried calling StatusBar.styleDefault, but the StatusBar plugin is not installed.
2020-11-10 12:42:59.725 25142-25142/? W/Capacitor/Console: File: http://localhost/vendor-es2015.js - Line 109561 - Msg: Install the StatusBar plugin: 'ionic cordova plugin add cordova-plugin-statusbar'
2020-11-10 12:42:59.726 25142-25142/? W/Capacitor/Console: File: http://localhost/vendor-es2015.js - Line 109555 - Msg: Native: tried calling SplashScreen.hide, but the SplashScreen plugin is not installed.
2020-11-10 12:42:59.727 25142-25142/? W/Capacitor/Console: File: http://localhost/vendor-es2015.js - Line 109561 - Msg: Install the SplashScreen plugin: 'ionic cordova plugin add cordova-plugin-splashscreen'
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
Describe the bug
Updating the plugin to the latest release v1.3.1 when I run "npx cap sync" this error appears:
[error] Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "GoogleUtilities/MethodSwizzler":
In Podfile:
CapacitorCommunityAdmob (from '../../node_modules/@capacitor-community/admob') was resolved to 0.0.1, which depends on
Google-Mobile-Ads-SDK (= 7.69.0) was resolved to 7.69.0, which depends on
GoogleAppMeasurement (~> 7.0) was resolved to 7.6.0, which depends on
GoogleUtilities/MethodSwizzler (~> 7.0)
CordovaPluginsStatic (from '../capacitor-cordova-ios-plugins') was resolved to 2.4.6, which depends on
GoogleUtilities (~> 6.7) was resolved to 6.7.0, which depends on
GoogleUtilities/MethodSwizzler (= 6.7.0)
I tried to run "pod install" or "pod update" but I get the same error
export class AdMobComponent {
private options: AdOptions = {
adId: 'YOUR ADID',
adSize: AdSize.BANNER,
position: AdPosition.BOTTOM_CENTER,
margin: 0,
// isTesting: true
npa: true // uncomment
};
It's just a my guesss ...
My app crashed after build.
This is error log
AdMob: rendering rootView
Fatal error: Unexpectedly found nil while unwrapping an Optional value: file CapacitorCommunityAdmob/Plugin.swift, line 107
2020-10-07 21:17:57.462271+0900 App[535:76189] Fatal error: Unexpectedly found nil while unwrapping an Optional value: file CapacitorCommunityAdmob/Plugin.swift, line 107
I added option of npa in AdOptions
.
My app was not crashed after build.
I think you have to change sample of README.md.
Describe the bug
I've followed all the steps, editing MainActivity.java, etc but AdMob is still undefined upon importing. Looking for tips on how to debug further, as I've hit a wall.
import {Plugins} from "@capacitor/core";
const {AdMob, App, Device} = Plugins;
Then in created() I call:
AdMob.initialize();
It compiles just fine and starts up on the emulator or my phone but then gives this error:
2021-01-09 16:17:15.684 15158-15158/com.kevins.app E/Capacitor/Console: File: http://localhost/js/chunk-vendors.458f2ac8.js - Line 7 - Msg: TypeError: Cannot read property 'initialize' of undefined
I'm using vue 2.x, but I don't think it matters.
Does android studio need to build the plugin or something first? I've checked after 'ionic cap sync android' and there's a 'capacitor-cordova-android-plugins' directory, but I'm not sure what to look for in there.
Plugin Issue or your implements issue?
I've tried to adapt the code examples for vue, so I think they're pretty correct. It feels like the problem is happening pretty early in the startup process.
There's no errors or warnings in the android build output.
On the web mode, it does show:
web-runtime.js:38 Uncaught (in promise) AdMob does not have web implementation.
Expected behavior
Had hoped an ad would show :)
Logcat
2021-01-09 16:17:15.064 15158-15158/com.kevins.app I/Capacitor/Console: File: http://localhost/js/app.f79a5628.js - Line 1 - Msg: admob init
2021-01-09 16:17:15.067 15158-15299/com.kevins.app D/Capacitor: Handling local request: http://localhost/js/chunk-198e3942.22b01d4d.js
2021-01-09 16:17:15.081 15158-15335/com.kevins.app W/m.kevins.ap: Accessing hidden method Lsun/misc/Unsafe;->getUnsafe()Lsun/misc/Unsafe; (greylist,core-platform-api, linking, allowed)
2021-01-09 16:17:15.082 15158-15335/com.kevins.app W/m.kevins.ap: Accessing hidden method Lsun/misc/Unsafe;->objectFieldOffset(Ljava/lang/reflect/Field;)J (greylist,core-platform-api, linking, allowed)
2021-01-09 16:17:15.082 15158-15335/com.kevins.app W/m.kevins.ap: Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
2021-01-09 16:17:15.082 15158-15335/com.kevins.app W/m.kevins.ap: Accessing hidden method Lsun/misc/Unsafe;->compareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z (greylist, linking, allowed)
2021-01-09 16:17:15.089 15158-15450/com.kevins.app D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2021-01-09 16:17:15.089 15158-15451/com.kevins.app W/m.kevins.ap: Accessing hidden method Lsun/misc/Unsafe;->compareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z (greylist, linking, allowed)
2021-01-09 16:17:15.093 15158-15299/com.kevins.app D/Capacitor: Handling local request: http://localhost/js/chunk-11e5012f.f0be9f85.js
2021-01-09 16:17:15.094 15158-15299/com.kevins.app D/Capacitor: Handling local request: http://localhost/js/chunk-198e3942.22b01d4d.js
2021-01-09 16:17:15.096 15158-15302/com.kevins.app D/Capacitor: Handling local request: http://localhost/js/chunk-1bef398e.8f7a182e.js
2021-01-09 16:17:15.104 15158-15302/com.kevins.app D/Capacitor: Handling local request: http://localhost/js/chunk-1f16206c.252d54f9.js
2021-01-09 16:17:15.108 15158-15318/com.kevins.app D/Capacitor: Handling local request: http://localhost/js/chunk-1bef398e.8f7a182e.js
2021-01-09 16:17:15.111 15158-15335/com.kevins.app W/m.kevins.ap: Accessing hidden method Lsun/misc/Unsafe;->compareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z (greylist, linking, allowed)
2021-01-09 16:17:15.112 15158-15335/com.kevins.app I/chatty: uid=10133(com.kevins.app) CapacitorPlugin identical 1 line
2021-01-09 16:17:15.121 15158-15335/com.kevins.app W/m.kevins.ap: Accessing hidden method Lsun/misc/Unsafe;->compareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z (greylist, linking, allowed)
2021-01-09 16:17:15.130 15158-15318/com.kevins.app D/Capacitor: Handling local request: http://localhost/js/chunk-1f16206c.252d54f9.js
2021-01-09 16:17:15.133 15158-15455/com.kevins.app W/m.kevins.ap: Accessing hidden method Lsun/misc/Unsafe;->compareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z (greylist, linking, allowed)
.. some more chunk loading
2021-01-09 16:17:15.684 15158-15158/com.kevins.app E/Capacitor/Console: File: http://localhost/js/chunk-vendors.458f2ac8.js - Line 7 - Msg: TypeError: Cannot read property 'initialize' of undefined
Thank you!
Describe the bug
Android App crashing on new project:
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.ViewGroup.addView(android.view.View)' on a null object reference
at com.getcapacitor.community.admob.AdMob$2.run(AdMob.java:188)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
To Reproduce
Create new ionic project, add android to capacitor, add this package. Add params to manifest, MainActivity and strings as stated in the readme. Run the app in android emulator.
Smartphone (please complete the following information):
Describe the bug
Banner options - (position, adSize) - were set, but they are not showing correctly as set in the options.
To Reproduce
Steps to reproduce the behavior:
[ app.component.ts ]
constructor(
private _platform: Platform,
) {
const isApp: boolean = this._platform.is('capacitor');
if (isApp) {
AdMob.initialize();
const options: AdOptions = {
adId: 'REAL_AD_ID',
adSize: AdSize.FULL_BANNER,
position: AdPosition.BOTTOM_CENTER,
margin: 0,
// isTesting: true,
// npa: true,
};
AdMob.showBanner(options);
}
}
Expected behavior
Expected: Ad is shown on bottom center with full width.
Actual: Ad is shown on top left hand corner, size is 320*50
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
"@capacitor-community/admob": "^1.2.5",
"@capacitor/android": "^2.4.2",
"@capacitor/core": "2.4.2",
Additional context
Add any other context about the problem here.
Describe the bug
Sometimes when open app
Google Play Console gives me the following info on the crashes:
java.lang.IllegalStateException: The ad unit ID can only be set once on InterstitialAd.
at com.google.android.gms.internal.ads.zzxx.setAdUnitId(com.google.android.gms:play-services-ads-lite@@19.1.0:80)
at com.google.android.gms.ads.InterstitialAd.setAdUnitId(com.google.android.gms:play-services-ads-lite@@19.1.0:17)
at com.getcapacitor.community.admob.helpers.AdViewIdHelper.assignIdToAdView(AdViewIdHelper.java:37)
at com.getcapacitor.community.admob.AdMob$2.run(AdMob.java:114)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Device:
Google Pixel 2 API 28
Other info:
my js code:
initializeApp() {
this.platform.ready().then(() => {
this.prepareConfig() ;
});
}
optionsInterstitial: AdOptions;
prepareConfig() {
if (Capacitor.platform !== 'web') {
AdMob.initialize();
this.prepareConfigInterstitial();
}
}
prepareConfigInterstitial() {
if (Capacitor.platform == 'ios') {
this.optionsInterstitial = {
adId: AppConfig.admob.interstitial.ios,
}
}
if (Capacitor.platform == 'android') {
this.optionsInterstitial = {
adId: AppConfig.admob.interstitial.android,
}
}
if (Capacitor.platform !== 'web') {
AdMob.prepareInterstitial(this.optionsInterstitial)
.then(
async (value: any) => {
console.log(value); // true
},
(error: any) => {
console.error(error); // show error
}
);
}
}
Describe the bug
Getting compilation error after migration to capacitor v2 and this plugin from 0.2 to 1.0.1.
Error is in MainAcitivity.java on the import app.xplatform.capacitor.plugins.AdMob
To Reproduce
Steps to reproduce the behavior:
Expected behavior
no compilation error
Desktop (please complete the following information):
Describe the bug
AdReward events just return {value: true}
which is not useful for apps with different reward options where the amount and reward type info is needed.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The event payload should carry the info about the obtained reward
I will start working at this after #18 is merged but just for Android. Sadly I do not have a Mac to do the iOS part.
Describe the bug
Banner on android doesnt want to start
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Android banner showing up.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
AdMob.showBanner({
adId: "ca-app-pub-5343465453645~23432546",
adSize: AdSize.SMART_BANNER,
position: AdPosition.TOP_CENTER,
margin: 0,
});
Error from logcat:
unable to connect to service: com.google.android.gms.auth.key.retrieval.service.START on com.google.android.gms
Hi everybody!
There's a way to disable or limitate volume of AdMob video ads (interstitial ads)?
Some of our users are annoyed by the high volume of these and we want to find a solution.
Reading on AdMob Google Developer website I've found this:
https://developers.google.com/admob/android/global-settings
https://developers.google.com/admob/ios/global-settings
There's a way to integrate on this plugin?
Thanks
Old Low Configuration mobile showing error Uncaught SyntaxError: Use of const in strict mode
E/Capacitor/Console: File: http://192.168.1.148:3000/ - Line 361 - Msg: SyntaxError: Unexpected strict mode reserved word
E/Capacitor: JavaScript Error: {"type":"js.error","error":{"message":"Uncaught SyntaxError: Unexpected strict mode reserved word","url":"http://192.168.1.148:3000/static/js/1.chunk.js","line":5237,"col":1,"errorObject":"{}"}}
E/Capacitor/Console: File: http://192.168.1.148:3000/static/js/1.chunk.js - Line 5237 - Msg: Uncaught SyntaxError: Unexpected strict mode reserved word
E/Capacitor/Console: File: http://192.168.1.148:3000/ - Line 361 - Msg: SyntaxError: Use of const in strict mode.
E/Capacitor: JavaScript Error: {"type":"js.error","error":{"message":"Uncaught SyntaxError: Use of const in strict mode.","url":"http://192.168.1.148:3000/static/js/main.chunk.js","line":464,"col":1,"errorObject":"{}"}}
E/Capacitor/Console: File: http://192.168.1.148:3000/static/js/main.chunk.js - Line 464 - Msg: Uncaught SyntaxError: Use of const in strict mode.
Describe the bug
A clear and concise description of what the bug is.
When compiling and uploading to itunne is not possible, it indicates that Swift functions are deprecated.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
Please let me know what am I missing.
AdMob.showInterstitial()
never show interstitial. Below is my code.
import React from 'react';
import { IonButton, IonContent, IonHeader, IonPage, IonTitle, IonToolbar, isPlatform } from '@ionic/react';
import { Plugins } from '@capacitor/core';
import { AdOptions } from '@capacitor-community/admob';
import './Tab3.css';
const { AdMob } = Plugins;
const Tab3: React.FC = () => {
AdMob.initialize();
const adId = {
ios: 'ca-app-pub-xxxx/xxx',
android: 'ca-app-pub-xxxx/xxx'
}
const platformAdId = isPlatform('android') ? adId.android : adId.ios;
const optionsInter: AdOptions = {
adId: platformAdId,
isTesting: true
//autoShow: true
}
const handleAd = async () => {
const adStatus = await AdMob.prepareInterstitial(optionsInter);
if(adStatus.value){
AdMob.addListener('onAdLoaded', (info: boolean) => {
// You can call showInterstitial() here or anytime you want.
console.log("InterInfo",info);
AdMob.showInterstitial();
});
// AdMob.showInterstitial();
console.log("GoodToGo");
}
}
return (
<IonPage>
<IonHeader>
<IonToolbar>
<IonTitle>Tab 3</IonTitle>
</IonToolbar>
</IonHeader>
<IonContent fullscreen>
<IonHeader collapse="condense">
<IonToolbar>
<IonTitle size="large">Tab 3</IonTitle>
</IonToolbar>
</IonHeader>
<IonButton onClick={handleAd}>Show Ad</IonButton>
</IonContent>
</IonPage>
);
};
export default Tab3;
Describe the bug
Interstitial ads are not being loaded on iOS.
AdMob.prepareInterstitial(options) just fails silently.
The same codes works on Android.
I'm guessing the problem is in file admob/ios/Plugin/Plugin.swift, line 281
Lines 281 to 282 in 7835645
Shouldn't it be GADInterstitial and
self.interstitial.load(GADRequest()) ?
Describe the bug
I can't import the AdMob
Plugin from @capacitor/core
with import { Plugins } from "@capacitor/core";const { AdMob} = Plugins;
.
I am using VSCode and the Object Plugins
does not include AdMob
and i dont get any autocompletition for it
To Reproduce
Steps to reproduce the behavior:
npm i --save @capacitor/admob
App.tsx
with import { Plugins} from "@capacitor/core"; const {AdMob} = Plugins;
Expected behavior
I expect VSCode to find the AdMob Class in Plugins
Desktop (please complete the following information):
Additional context
I hope i am not just too stupid for it
In open source repo is hard or impossible ask all the developers to keep the same environment, IDEs, plugins and OS are different with different configurations and preferences.
The project already uses Prettier as commit hook, but no prettier config and editor config file are to be found, this leads to prettier to search locally if some kind of config exist or to use the defaults if not.
Example: #18
Having prettier and editorconfig assures that each the files will have the same format across all OS or IDEs.
As it seems google claims that the ads are triggered after the application is closed. The update i did had no changes in the code about the triggering of the ads.
Probably something changed at the algorithm of google store. I also cannot recreate the claims of google.
The ad i use is an interstitial. It is triggered from a user action. Also i check from the platform { App }, the state of the application before i show the ad.
Those are the dependencies i use
"dependencies": {
"@angular/common": "^9.0.1",
"@angular/core": "^9.0.1",
"@angular/forms": "^9.0.1",
"@angular/platform-browser": "^9.0.1",
"@angular/platform-browser-dynamic": "^9.0.1",
"@angular/router": "^9.0.1",
"@capacitor-community/admob": "^1.0.1",
"@capacitor/android": "^2.2.0",
"@capacitor/cli": "^2.2.0",
"@capacitor/core": "^2.2.0",
"@capacitor/ios": "^2.2.0",
"@ionic/angular": "^5.2.2",
"@ionic/app-scripts": "^3.2.4",
"chart.js": "^2.8.0",
"core-js": "^2.5.4",
"css-loader": "^3.4.2",
"jetifier": "^1.6.6",
"karma-coverage": "^2.0.1",
"karma-phantomjs-launcher": "^1.0.4",
"rxjs": "^6.5.4",
"to-string-loader": "^1.1.5",
"tslib": "^1.9.0",
"webpack": "^4.41.6",
"zone.js": "^0.10.2"
},
I believe i tested everything that will fix the problem at the typescript code, except from changing the type of ad itself.
Describe the bug
Multiple rewards will be acquired when reward videos are shown in the second time.
To Reproduce
Steps to reproduce the behavior:
AdMob.showRewardVideoAd();
AdMob.addListener('onRewarded', (info) => {
console.log(info)
}
Expected behavior
Only one console.log is shown during the second time
Screenshots
If applicable, add screenshots to help explain your problem.
Smartphone (please complete the following information):
Android 10
Additional context
Add any other context about the problem here.
For Capacitor 3, imports on Plugins are changing. You should be able to import Plugins directly from the npm package like this.
import { AdMob } from '@capacitor-community/admob';
I've added this issue to the Capacitor 3.0.0 milestone and I'm happy to help out with the migration to Capacitor 3 ๐
See:
Context:
AdMob Mediation is a feature that lets you serve ads to your apps from multiple sources, including the AdMob Network, third-party ad networks, and AdMob campaigns. AdMob Mediation helps maximize your fill rate and increase your monetization by sending ad requests to multiple networks to ensure you find the best available network to serve ads.
Describe the bug
This only applies to Android, iOS is working as expected!
When loading an ad with the AdSize.BANNER (the dumb version, not the smart one) and the AdPosition.BOTTOM_CENTER, the ad is loaded and displayed. But it appears left aligned instead of centered. This can be reproduced in my app as well as in the example app if the AdSize is changed from .SMART_BANNER to .BANNER for either the top or bottom ad.
Expected behavior
I expect the banner to be centered, as the AdPosition indicates and as it does on iOS 14.1.
Plugin
Version 1.2.4
Smartphone:
Android 29 in simulator and on a real device, when the screen width is greater than 320px
Thank you developers for your effort in creating this plugin. It would be great if we could have types and interfaces for methods and properties for Angular-Ionic developers. For example, "addListener()" is of type: any currently. Thanks in advance.
After installing latest version:
"@capacitor-community/admob": "^3.0.0-1"
i cannot use the plugin on Android. Tested on emulators, Pixel 3a (Android 10), Pixel 4 (Android 11) and on actual device Pixel 4a (Android 11)
Sample code:
import { AdMob, AdOptions, AdPosition, AdSize } from '@capacitor-community/admob';
...
const success = await AdMob.initialize({});
Which fails on the initialization with:
ERROR Error: Uncaught (in promise): Error: "AdMob" plugin is not implemented on android
Error: "AdMob" plugin is not implemented on android
Before the update i used the v1.2.6, with the appropriate imports, which worked as expected.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.