cordova-plugin-nativestorage
cordova-plugin-nativestorage copied to clipboard
NativeStorage is not defined
I just added this plugin to my Telerik Cordova Project but when i go to use it i get 'NativeStorage is not defined' this is the only plugin i have installed that i cant seem to get working.
here is a sample of the code im been trying
document.addEventListener('deviceready', function () {
app.mobileApp.pane.loader.element.addClass("oversii-loader");
$("#navigation-container").append('<li><a onclick="app.logout();" data-icon="contacts" class="km-listview-link"><span class="km-icon km-contacts"></span>Logout</a></li>');
console.log("App", app);
console.log("Window", window);
console.log("feedback", window.feedback);
var obj = {name: "NativeStorage", author: "GillesCallebaut"};
NativeStorage.set("reference", obj, function(e) {alert('success')}, function(e) {alert("erros")});
}, false);
I just had this issue and used "window.NativeStorage" not just "NativeStorage". However, this only worked in a build of the App and did not work in the Simulator or the Cordova Developer App.
cc @GillesC
Have you installed the plugin through the Cordova CLI or the AppBuilder of Telerik?
I have a similar issue trying to use the plugin with Angular 4. No matter how I reference NativeStorage
it is always undefined
.
I have faced similar issue ,i resolved it by adding the Plugin name in config.xml file in the following way
<feature name="NativeStorage">
<param name="ios-package" value="NativeStorage"/>
</feature>
Resolved similar issue by adding
<script src="cordova.js"></script>
to index.html. This made 'deviceready' event start to fire and NativeStorage became available.
When I use NativeStorage to debug in desktop browser env, I find It's not initialized at first, so I use a interval to check whether it is attached to window then start my app.
os: mac osx 10.11
chrome 66
I also have the same problem. I installed the plugin via the phonegap CLI. The plugin works perfectly on the browser, however is undefined on the phone. What could be the reason for this ?
Same issue here when running the app with ionic serve
.
Android and iOS on real device is fine, but on simulator sometimes are “not defined”.
Any guess?