Cordova plugins can't execute javascript code with webView.loadUrl
See original GitHub issueDescription of the problem:
It seems like Capacitor does not allow for Cordova cordova.fireDocumentEvent
to be received using document.addEventListener
.
I’m using the Cordova Admob Free plugin with Capacitor. The plugin installs and works as expected, meaning the bridge calls work and it displays test ads, however, my Capacitor app does not receive any of the plugin issued cordova.fireDocumentEvent events.
Affected platform
- Android
- iOS
- electron
- web
OS of the development machine
- Windows
- macOS
- linux
Other information:
I’ve tried with both Cordova framework 7.0.0 and 8.0.0 as dependencies in the Android project.
Capacitor version: 1.0.0-beta.19
node version: 11.7.0
npm version: 6.5.0
CocoaPods version:
Steps to reproduce:
- Clone and build the repository at https://github.com/petarov/capacitor-cordova-fireevent
npx cap open android
to open the app in Android Studio.- Build & run the app on an Android device.
- Open Logcat in Android Studio.
- Press the
Show Ad
button in the app on the device. - None of the
admob.interstitial.events.*
events in app.js get displayed in Logcat.
Link to sample project: https://github.com/petarov/capacitor-cordova-fireevent
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Ok, I got the test APPLICATION_ID and was able to test and fix it.
BTW, don’t manually edit anything in capacitor-cordova-android-plugins, all that is recreated on update and sync commands.
You can add the id on the app’s AndroidManifest.xml like this
(It requires to add the tools namespace to the manifest tag
xmlns:tools="http://schemas.android.com/tools"
)I’ve just tested the fix and it all works great! Thank you again @jcesarmobile and thanks for the id hint.
I’m sorry about the missing
capacitor-cordova-android-plugins
folder. Looks like it was in the.gitignore
file Capacitor generated and I completely missed it. My bad!