apla / me.apla.cordova.app-preferences

App preferences plugin for cordova
Apache License 2.0
201 stars 209 forks source link

No stored values after application reload #33

Closed matuskopo closed 9 years ago

matuskopo commented 9 years ago

Hello,

plugin works on latest cordova 5.0.0 apps, but when I restart the application (or reload app's webview), nothing is stored in preferences anymore. During application lifecycle it's OK.

Bye

apla commented 9 years ago

What platform you're using?

matuskopo commented 9 years ago

I was testing it on Android and iOS. I've created preferences files with script from bin directory of plugin, but there was also bug, cause script is creating file "platforms/android/res/xml/apppreferences.xml" for Android. But in Activity class it wants to read from "R.xml.preferences" file. So I had to rename apppreferences.xml to preferences.xml in res/xml folder, to build it successfully for Android.

apla commented 9 years ago

please test your app: https://gist.github.com/apla/71ffbda54a5ca7e6e0df

matuskopo commented 9 years ago

I've tested it, and you are right, that number is incrementing, even after application restart. What I've problem with what, that I have no plugins object defined, unless DeviceReady event is fired. So I've defined prefs object in deviceReady callback as this:

app.prefs = plugins.appPreferences;

app is standard cordova application related object. I will try to define it as "var prefs" and just to initialize it in deviceReady callback. Will give you feedback then.

Thanks

matuskopo commented 9 years ago

Oh man. Please forget this issue. Problem was ME. When storing values I forgot to wait for success callback and I was doing other actions immediately in my App. So I think, values were never stored successfully. As your test is working great. Sorry for that. Thank you

apla commented 9 years ago

at least one issue is fixed on my side -)