Code Monkey home page Code Monkey logo

Comments (16)

alokrajiv avatar alokrajiv commented on September 14, 2024

could you specify the platform you are using Android/iOS and the version.

from cordova-plugin-nativestorage.

marianfeiler avatar marianfeiler commented on September 14, 2024

I am working on iOS 9.3.1

from cordova-plugin-nativestorage.

alokrajiv avatar alokrajiv commented on September 14, 2024

I am able to run it on iOS v9.3 without any issues.
could you run
cordova plugin ls
and confirm output of the above command to have:
cordova-plugin-nativestorage 1.0.9 "NativeStorage".

from cordova-plugin-nativestorage.

marianfeiler avatar marianfeiler commented on September 14, 2024

I confirm the output, see below:

iMac:mySprit marianfeiler$ sudo cordova plugin ls 
cordova-plugin-console 1.0.2 "Console"
cordova-plugin-nativestorage 1.0.9 "NativeStorage"
cordova-plugin-statusbar 1.0.1 "StatusBar"

from cordova-plugin-nativestorage.

alokrajiv avatar alokrajiv commented on September 14, 2024

@marianfeiler
I noticed you are using typeof nativeStorage
could you try with typeof NativeStorage with the first letter 'n' as capital 'N'.

from cordova-plugin-nativestorage.

marianfeiler avatar marianfeiler commented on September 14, 2024

I tried, but i run in Error.
But I tried and tried, and then, I think it was Build Error with Phonegap.
Now it works like a charm :)
But I think the handling could be nicer... like just so for setting:
var result = nativeStorage.set("foo", "bar"); // returns true|false
or for getting:
var myString = nativeStorage.getString("foo"); // returns String (bar) and in error false
Thanks again a lot for helping...

from cordova-plugin-nativestorage.

alokrajiv avatar alokrajiv commented on September 14, 2024

Great to know you got it working. So, thank you for confirming. I am closing this issue.
Also we don't have a return type, because the operation is asynchronous.
So, for errors as-per Javascript standards, you could use the 4rd parameter of NativeStorage.set() to pass an error handler function, which will be called with the error as parameter.

from cordova-plugin-nativestorage.

GillesC avatar GillesC commented on September 14, 2024

I've opted for callback functions because of the nature of JavaScript. It's an inherent strategy used in JavaScript. It makes asynchronuous communication possible. Thus, not blocking the rest of the code. The overhead introduced by Cordova is in that manner less obvious.

from cordova-plugin-nativestorage.

Neo1975 avatar Neo1975 commented on September 14, 2024

Hi,
I had the same problem. After many test try and debugging I understand that: angular application, service and controller are initialized before cordova plugins. So in my case I use NativeStorage object at Service startup.
To avoid problems I suggest you to:

  • Remove ng-app from body
  • put this cose at the end of index.html

<script type="text/javascript"> document.addEventListener('deviceready', function onDeviceReady() { angular.bootstrap(document.querySelector('body'), ['starter']); }, false); </script>

Instead I would like to advice @GillesC to insert this instructions inside Readme file.

from cordova-plugin-nativestorage.

GillesC avatar GillesC commented on September 14, 2024

@Neo1975 I've written a wrapper, can u see if the problem persists when using the wrapper to access the NativeStorage functionalities. If so I will include your instructions for this problem in the README, otherwise the users should use the wrapper for using the plugin in Ionic or other AngulerJS related frameworks.

Edit: the wrapper only wraps the functionalities provided as of v2.

from cordova-plugin-nativestorage.

Neo1975 avatar Neo1975 commented on September 14, 2024

Indeed, I imported wrapper project as you describe in the ReadMe file: the
exception is throw by getItem and setItem method found NativeStorage
undefined. Perhaps can depends on Ionic Framework but in the way that I
describe above now works well.

Il giorno ven 27 mag 2016 alle ore 18:04 Gilles Callebaut <
[email protected]> ha scritto:

@Neo1975 https://github.com/Neo1975 I've written a wrapper
https://github.com/TheCocoaProject/ngcordova-wrapper-nativestorage, can
u see if the problem persists when using the wrapper to acces the
NativeStorage functionalities. I so I will include your instructions for
this problem in the README, otherwise the users should use the wrapper for
using the plugin in Ionic or other AngulerJS related frameworks.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#10 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AA9iQFhb0Bx12lR647B-D7bU2bDoRm36ks5qFxYfgaJpZM4IMl75
.

from cordova-plugin-nativestorage.

GillesC avatar GillesC commented on September 14, 2024

@Neo1975 Thanks for your contribution, I will update the readme and will look further into the matter, when I have more time.

from cordova-plugin-nativestorage.

jwuliger avatar jwuliger commented on September 14, 2024

Hello. I know this is closed, but I am trying to use the fix described by @Neo1975. I am not able to get my angular app to run. Is there a more specific place that I place the javascript bootstrapper after I remove ng-app from my body tag? Thanks so much for any help.

from cordova-plugin-nativestorage.

alokrajiv avatar alokrajiv commented on September 14, 2024

hi @jwuliger, not very familiar with the exact issue, but did you try to bootstrap after onready using the script as mentioned by @Neo1975.

from cordova-plugin-nativestorage.

jwuliger avatar jwuliger commented on September 14, 2024

Hello @alokrajiv Thanks for the reply. Yes, I am using the script as suggested, just changed the app name. I have tried placing it in many different locations at the bottom of my index.html file. Here is a snippet:

    /// all my angular/ionic & app js is above ///
    <script src="lib/ngcordova-wrapper-nativestorage/dist/ngcordova-wrapper-nativestorage.min.js"></script>
</head>

<body> <!--ng-app="app"-->
    <ion-nav-view></ion-nav-view>
</body>
    <script type="text/javascript">
        document.addEventListener("deviceready", function onDeviceReady() {
            angular.bootstrap(document.querySelector("body"), ["app"]);
        }, false);
    </script>
</html>

I suppose this was the solution to getting "undefined" when using a get call when there is nothing in storage yet. Like I said I have tried many iterations of the code placement. Maybe I something else in the wrong place. Thanks for your help!

from cordova-plugin-nativestorage.

alokrajiv avatar alokrajiv commented on September 14, 2024

@jwuliger Which version of angular are you using? also are you using ionic? without ionic I am able to inject $cordovaNativeStorage without any troubles using ng-app itself, no bootstrapping.

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.