When I\'m running my Ionic app with ionic serve -l
command, get following error message:
Runtime Error
Unca
Cordova is only accessible when you run your app on a real device. When you test your app in the browser, it cannot access those native plugins.
You can check if you are on a real device or a browser like that:
if (this.platform.is('cordova')) {
// You are on a device, cordova plugins are accessible
} else {
// Cordova not accessible, add mock data if necessary
}
This will only help you test the parts of your app that don't rely on cordova plugins. To really test your app, you need to run it on a device or in the emulator.
Maybe something has changed since then, but Ionic now supports the "browser" as a platform ( vs simply browse ) - which makes the Cordova plugins available in the browser.
To use it you add the platform ionic cordova platform add browser
And then you run ionic cordova run browser
vs ionic serve
( ionic run browser
- just like ionic cordova run android
or ionic cordova run ios
)