I am writing some key/values on my phonegap app with javascript on the html5 localstorage, but I want to access them when my app is starting, specifically from my objective-c +(NSString*) startPage method.
I know I can do it from -(void) webViewDidFinishedLoad, but I need to read the the values from the startPage method, so that I can retrieve the page names that I will store and use like start page. Is there any way to do that? If not, Is there any way to set the start page with a string that was saved on the localstorage? Any suggestion will be very appreciated.
I am writing some key/values on my phonegap app with javascript on the html5
Share
You’d have to write native code to access the local storage. I believe that HTML local storage data is stored as an SQLLite database in your application’s library folder, so you should be able to access it using the native SQLLite interfaces, although that sounds like kinda hard work for what you are trying to do.
A simpler solution might be to use PhoneGap to write your data to the NSUserDefaults using a plugin instead of storing it in local storage. It’s pretty easy to pass that data to and from the webview once it’s loaded using the plugin interface, and it’s a lot simpler to access NSUserDefaults from native code than the local storage database.