Comments (16)
could you specify the platform you are using Android/iOS and the version.
from cordova-plugin-nativestorage.
I am working on iOS 9.3.1
from cordova-plugin-nativestorage.
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.
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.
@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.
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.
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.
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.
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.
@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.
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.
@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.
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.
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.
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.
@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)
- Ionic 3 - No provider for NativeStorage HOT 1
- Values not consistent HOT 1
- IOS doesn't work HOT 6
- getItem returns JSON_ERROR trying to get a value stored using objective c
- losing data on ios HOT 5
- retrieving data from another app HOT 1
- How can i get value from NativeStorage.getString() Without Using Callbacks? HOT 1
- Undefined data in iOS when trying to store data
- NativeStorage.keys func returns un known keys by default on IOS
- Angular Cordova app stucks at splash screen on iOS 13+ HOT 1
- Please, close this issue.
- Ionic Native Storage not working Android 9+ HOT 5
- Is this project being maintained? HOT 2
- MFP v8.o Push Rest Service Implementation sample java project or adapter HOT 1
- IOS build issue HOT 1
- Migrate data to React Native HOT 2
- Experience slow in ionic native storage in android version(sharedpreferences)
- iOS - setItem function always returns the wrong callback (Error storing item)
- Outdated values after installing new version of the app
- iOS - Privacy Manifest
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-nativestorage.