Ionic 2 has a Native Storage component for iOS and Android: https://ionicframework.com/docs/v2/native/nativestorage/
In the repo's readme (https://github.com/TheCocoaProject/cordova-plugin-nativestorage) is said that there is support for browser environment (it uses the LocalStorage fom the browser).
I tried to use it but when I run my Ionic in browser (ionic serve) the browser outputs something like this:
main.js:224 Native: tried calling NativeStorage.setItem, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
In the browser environment the cordova is not injected. This makes senses, as long as the cordova.js only works for integration with the device's API.
Anyone knows if it is possible to use this plugin in the browser?
Ionic Storage abstracts all available mechansims for data storage such as native Cordova SQLite and browser storage APIs like IndexedDB, WebSQL or localStorage.
Testing your app in a browser is as simple as running the serve command in your project's root folder. This will start a live-reload server for your project.
Because Ionic is based on web technologies, it works just as well on desktop browsers as it does on mobile devices.
Ionic / cordova made some changes in the CLI.
The command to run with plugins is now
ionic cordova run browser
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With