Code Monkey home page Code Monkey logo

Comments (10)

GillesC avatar GillesC commented on August 10, 2024

Options:

  • Are you sure the plugin is correctly installed for iOS? Please retry to install the plugin again (by removing and adding it).
  • If your using Ionic 2 please check the official Ionic Native docs.
  • I noticed http://localhost:8100 in your error messages. What happens when you build the binary and install it to your device or simulator rather than trying to use ionic serve or similar?

from cordova-plugin-nativestorage.

tranjustin avatar tranjustin commented on August 10, 2024

I was able to get it working. I am running into another issue. I am trying to use this plugin to do persistent login. However, the storage gets clear when the app is closed.

From: Gilles Callebaut
Reply-To: TheCocoaProject/cordova-plugin-nativestorage
Date: Tuesday, August 2, 2016 at 9:45 PM
To: TheCocoaProject/cordova-plugin-nativestorage
Cc: jttran, Author
Subject: Re: [TheCocoaProject/cordova-plugin-nativestorage] Uncaught ReferenceError: NativeStorage is not defined, http://localhost:8100/lib/ionic/js/ioni c.bundle.js, Line: 17946 (#30)

_SRP EXTERNAL WARNING: PROCEED WITH CAUTION. WHEN IN DOUBT, REPORT IT!_


Are you sure the plugin is correctly installed for iOS? Please retry to install the plugin again (by removing and adding it). If your using Ionic 2 please check the official Ionic Native docshttps://urldefense.proofpoint.com/v2/url?u=http-3A__ionicframework.com_docs_v2_native_native-2Dstorage_&d=CwMFaQ&c=akfg7FU5kpSpmm2ZSGIDmg&r=nVqS0RlVX30vkYmdV83xzLwshgnwTA1tdqLhzmddqfc&m=LROzFA51auW6ImPO7Rgss_W4wdTkD81mWjn4pF39_gQ&s=gsbzh9fwcpF-04_QkNv3qheL61A_xTxsFsJP5OGaCHY&e=.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_TheCocoaProject_cordova-2Dplugin-2Dnativestorage_issues_30-23issuecomment-2D237137113&d=CwMFaQ&c=akfg7FU5kpSpmm2ZSGIDmg&r=nVqS0RlVX30vkYmdV83xzLwshgnwTA1tdqLhzmddqfc&m=LROzFA51auW6ImPO7Rgss_W4wdTkD81mWjn4pF39_gQ&s=AiKkGTmpDrIo4h4We8-kyJ_A9atrSsKT1y6PSVwsWqs&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AE-2Db-2D-2DJZlg8OpTX5DDXE8V29zEQcukiSks5qcBzqgaJpZM4JYrJh&d=CwMFaQ&c=akfg7FU5kpSpmm2ZSGIDmg&r=nVqS0RlVX30vkYmdV83xzLwshgnwTA1tdqLhzmddqfc&m=LROzFA51auW6ImPO7Rgss_W4wdTkD81mWjn4pF39_gQ&s=9KpWoqnfCOixEkBXVFsJP1HaTxfKwFQhlNXAqhUBig8&e=.

from cordova-plugin-nativestorage.

GillesC avatar GillesC commented on August 10, 2024

@tranjustin are you sure the fault lies with the plugin?

  • Are you storing the values correctly?
  • Are you retrieving the values correctly (by using the same reference string AND the same method of storing, e.g. getItem only works when storing the value by means of setItem, getInt only with setInt,...) ?
  • Are you also sure that you do not invoke the clear method when closing the app?

from cordova-plugin-nativestorage.

alokrajiv avatar alokrajiv commented on August 10, 2024

@tranjustin technically the storage shouldn't be cleared. Are you seeing any error on the console?

from cordova-plugin-nativestorage.

tranjustin avatar tranjustin commented on August 10, 2024

I don’t believe it is the plugin. I got it working on the browser but not on the devices or emulators. To answer you Gilles, I am sure that I am storing and retrieving correctly from a browser perspective but don’t know what I might missed on the devices.

From: Gilles Callebaut
Reply-To: TheCocoaProject/cordova-plugin-nativestorage
Date: Wednesday, August 3, 2016 at 2:27 PM
To: TheCocoaProject/cordova-plugin-nativestorage
Cc: jttran, Mention
Subject: Re: [TheCocoaProject/cordova-plugin-nativestorage] Uncaught ReferenceError: NativeStorage is not defined, http://localhost:8100/lib/ionic/js/ioni c.bundle.js, Line: 17946 (#30)

_SRP EXTERNAL WARNING: PROCEED WITH CAUTION. WHEN IN DOUBT, REPORT IT!_


@tranjustinhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_tranjustin&d=CwMFaQ&c=akfg7FU5kpSpmm2ZSGIDmg&r=nVqS0RlVX30vkYmdV83xzLwshgnwTA1tdqLhzmddqfc&m=CAXb5wFys-y38r8N-m-OWPJ1O1FbPEyhAJGbwYuCj8E&s=5p6T9kRthaBPbkVBEXV5St95oAeCBCqZCs1VzMd9KDI&e= are you sure the fault lies with the plugin?

  • Are you storing the values correctly?
  • Are you retrieving the values correctly (by using the same reference string AND the same method of storing, e.g. getItem only works when storing the value by means of setItem, getInt only with setInt,...) ?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_TheCocoaProject_cordova-2Dplugin-2Dnativestorage_issues_30-23issuecomment-2D237379793&d=CwMFaQ&c=akfg7FU5kpSpmm2ZSGIDmg&r=nVqS0RlVX30vkYmdV83xzLwshgnwTA1tdqLhzmddqfc&m=CAXb5wFys-y38r8N-m-OWPJ1O1FbPEyhAJGbwYuCj8E&s=edpjtubNO0RDVO6582JxP9nFPHojOkQKGs1WY5bRVV8&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AE-2Db-2D7Mkhn4hPOLXgPdVVMvEKH6hb1hkks5qcQfRgaJpZM4JYrJh&d=CwMFaQ&c=akfg7FU5kpSpmm2ZSGIDmg&r=nVqS0RlVX30vkYmdV83xzLwshgnwTA1tdqLhzmddqfc&m=CAXb5wFys-y38r8N-m-OWPJ1O1FbPEyhAJGbwYuCj8E&s=vVJLMqUkhBXEsiSIRrvaiNgi8aw4jxpI8SPeRfPQhQA&e=.

from cordova-plugin-nativestorage.

alokrajiv avatar alokrajiv commented on August 10, 2024

@tranjustin by browser, do you mean the browser platform?

from cordova-plugin-nativestorage.

GillesC avatar GillesC commented on August 10, 2024

Can you please show us the code which should store and retrieve the values? And please do explain how you build, on the devices/browser?

And another 'question' can you please explain in this thread how you've solved the 'Uncaught referenceError' for future cases? Some people can come to the same issue in the future :)

from cordova-plugin-nativestorage.

tranjustin avatar tranjustin commented on August 10, 2024
function loadUserCredentials() {
    return $q(function(resolve,reject){
        $log.log("load credential");
        var storedToken = $cordovaNativeStorage.getItem(LOCAL_TOKEN_KEY).then(function(value){
          $log.log("success load");
          $log.log(value);
        }, function(error){
          $log.log("error load");
          $log.log(error.message);
        });
        var authorizationStatus = storedToken.$$state;
        if (storedToken && authorizationStatus.status == 1) {
          var authorizationData = authorizationStatus.value;
          useCredentials(authorizationData);
          $log.log(authorizationData);
          resolve(authorizationData);
        }
        reject();
      });
    }

  function storeUserCredentials(authenticationData, keepmelogin) {
    var defer = $q.defer();
    if(!keepmelogin){
      authenticationData.refresh_token = "";
    }
    authenticationData.keepmelogin = keepmelogin;
    $cordovaNativeStorage.setItem(LOCAL_TOKEN_KEY, authenticationData).then(function(value){
      $log.log("success store");
      $log.log(value.name);
    }, function(error){
      $log.log("error store");
      $log.log(error.exception);
    });;
    useCredentials(authenticationData);
  }

Those two methods are in service that I call on $scope.$on('$ionicView.enter', function (){..}). When I deployed using Xcode I see this message “Resetting plugins due to page load”. Unfortunately, I didn’t see any error. I see the error string I logged but I don’t see the properties of the actual error I got back. I have tried error.exception and error.message. Do you know the properties inside the error that returns back?
[cid:FC409250-3A41-4311-B524-3FA1B68D3A95]

From: Gilles Callebaut
Reply-To: TheCocoaProject/cordova-plugin-nativestorage
Date: Wednesday, August 3, 2016 at 2:34 PM
To: TheCocoaProject/cordova-plugin-nativestorage
Cc: jttran, Mention
Subject: Re: [TheCocoaProject/cordova-plugin-nativestorage] Uncaught ReferenceError: NativeStorage is not defined, http://localhost:8100/lib/ionic/js/ioni c.bundle.js, Line: 17946 (#30)

_SRP EXTERNAL WARNING: PROCEED WITH CAUTION. WHEN IN DOUBT, REPORT IT!_


Can you please show us the code which should store and retrieve the values? And please do explain how you build, on the devices/browser?

And another 'question' can you please explain in this thread how you've solved the 'Uncaught referenceError' for future cases? :)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_TheCocoaProject_cordova-2Dplugin-2Dnativestorage_issues_30-23issuecomment-2D237381534&d=CwMFaQ&c=akfg7FU5kpSpmm2ZSGIDmg&r=nVqS0RlVX30vkYmdV83xzLwshgnwTA1tdqLhzmddqfc&m=Q6edWYEO_CfOY06O4dne2aGolfaeXMdjW74yd0RcwDA&s=ir1Osxt8M4Z9hNT-O4TqMbzF-xeqr6VXcmwytXULElI&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AE-2Db-2D6E9dBARZpVf3QwrEH9dr169UzjUks5qcQlNgaJpZM4JYrJh&d=CwMFaQ&c=akfg7FU5kpSpmm2ZSGIDmg&r=nVqS0RlVX30vkYmdV83xzLwshgnwTA1tdqLhzmddqfc&m=Q6edWYEO_CfOY06O4dne2aGolfaeXMdjW74yd0RcwDA&s=z8xGQg_rIkAdk5NgRNai6elDHixoX-FxWEDfMLgxjkE&e=.

from cordova-plugin-nativestorage.

tranjustin avatar tranjustin commented on August 10, 2024

I forgot to mention I solved the "Uncaught referenceError” by upgrading ngcordova and this is the script I put in the index.html

<script type="text/javascript"> angular.element(document).ready(function () { if (window.cordova) { console.log("Running in Cordova, will bootstrap AngularJS once 'deviceready' event fires."); document.addEventListener('deviceready', function () { console.log("Deviceready event has fired, bootstrapping AngularJS."); angular.bootstrap(document.body, ['starter']); }, false); } else { console.log("Running in browser, bootstrapping AngularJS now."); angular.bootstrap(document.body, ['starter']); } }); </script>

From: Gilles Callebaut
Reply-To: TheCocoaProject/cordova-plugin-nativestorage
Date: Wednesday, August 3, 2016 at 2:34 PM
To: TheCocoaProject/cordova-plugin-nativestorage
Cc: jttran, Mention
Subject: Re: [TheCocoaProject/cordova-plugin-nativestorage] Uncaught ReferenceError: NativeStorage is not defined, http://localhost:8100/lib/ionic/js/ioni c.bundle.js, Line: 17946 (#30)

_SRP EXTERNAL WARNING: PROCEED WITH CAUTION. WHEN IN DOUBT, REPORT IT!_


Can you please show us the code which should store and retrieve the values? And please do explain how you build, on the devices/browser?

And another 'question' can you please explain in this thread how you've solved the 'Uncaught referenceError' for future cases? :)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_TheCocoaProject_cordova-2Dplugin-2Dnativestorage_issues_30-23issuecomment-2D237381534&d=CwMFaQ&c=akfg7FU5kpSpmm2ZSGIDmg&r=nVqS0RlVX30vkYmdV83xzLwshgnwTA1tdqLhzmddqfc&m=Q6edWYEO_CfOY06O4dne2aGolfaeXMdjW74yd0RcwDA&s=ir1Osxt8M4Z9hNT-O4TqMbzF-xeqr6VXcmwytXULElI&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AE-2Db-2D6E9dBARZpVf3QwrEH9dr169UzjUks5qcQlNgaJpZM4JYrJh&d=CwMFaQ&c=akfg7FU5kpSpmm2ZSGIDmg&r=nVqS0RlVX30vkYmdV83xzLwshgnwTA1tdqLhzmddqfc&m=Q6edWYEO_CfOY06O4dne2aGolfaeXMdjW74yd0RcwDA&s=z8xGQg_rIkAdk5NgRNai6elDHixoX-FxWEDfMLgxjkE&e=.

from cordova-plugin-nativestorage.

tranjustin avatar tranjustin commented on August 10, 2024

Fix by using this script in index.html
angular.element(document).ready(function () {
if (window.cordova) {
console.log("Running in Cordova, will bootstrap AngularJS once 'deviceready' event fires.");
document.addEventListener('deviceready', function () {
console.log("Deviceready event has fired, bootstrapping AngularJS.");
angular.bootstrap(document.body, ['starter']);
}, false);
} else {
console.log("Running in browser, bootstrapping AngularJS now.");
angular.bootstrap(document.body, ['starter']);
}
});

from cordova-plugin-nativestorage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.