I’d like to see native plugins working in my browser when I’m developing, but I get the error “Native: tried calling NativeGeocoder.reverseGeocode, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator”
So Cordova might have a way to simulate that, but not Capacitor. To those who use Cordova, the general solution would be to run “ionic cordova run browser” but I get
“[ERROR] Refusing to use Cordova inside a Capacitor project”
But if I try to run “ionic capacitor run browser”, I get:
“[error] platform browser not found”
What can I do to run native plugins in web platform?
Cordova
and Capacitor
are different frameworks. Most of Cordova
plugins only support mobile platforms (iOS, Android...), and you can't use them in your browser, as you pointed it out in your question with the NativeGeocoder
plugin.
Capacitor
main objective is to help developers create mobile applications with Ionic, which can be used as PWA. That's why Capacitor
plugins are supported on the browser platform.
For example, capacitorgeolocation works with ionic serve
, while the cordova-plugin-geolocation does not work on the web (you will receive a message "Cordova not available").
But Capacitor does not provide yet any NativeGeocoder
plugin, so if you want to geocode addresses on the web, your only solution is to rely on API web services (like Mapbox or Google Maps). Because the NativeGeocoder
plugin relies on native code to work.