cordova-plugin-nativestorage icon indicating copy to clipboard operation
cordova-plugin-nativestorage copied to clipboard

NativeStorage is not defined

Open LorenDorez opened this issue 7 years ago • 9 comments

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);

LorenDorez avatar Oct 20 '17 15:10 LorenDorez

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.

keysk avatar Nov 09 '17 08:11 keysk

cc @GillesC

alokrajiv avatar Dec 05 '17 03:12 alokrajiv

Have you installed the plugin through the Cordova CLI or the AppBuilder of Telerik?

GillesC avatar Dec 06 '17 15:12 GillesC

I have a similar issue trying to use the plugin with Angular 4. No matter how I reference NativeStorage it is always undefined.

alsoicode avatar Feb 12 '18 22:02 alsoicode

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>

hari5004 avatar Feb 27 '18 04:02 hari5004

Resolved similar issue by adding

<script src="cordova.js"></script>

to index.html. This made 'deviceready' event start to fire and NativeStorage became available.

LKruglov avatar Mar 28 '18 02:03 LKruglov

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

catalsdevelop avatar Jun 05 '18 13:06 catalsdevelop

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 ?

TakshPSingh avatar Jun 25 '18 18:06 TakshPSingh

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?

douglasjunior avatar Jun 22 '23 14:06 douglasjunior