We are transitioning away from PhoneGap to a truly native iPhone app and we need to access user data stored in HTML5 local storage created by PhoneGap. How do we get at that data so that we can create a seamless update process for the user?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
I haven't tried Mattias' way but I just accessed the webkit local storage database directly and then imported the sqlite3 lib included with the iPhone SDK to extract the values I needed. This is how you access localstorage created by PhoneGap:
I just provide some detail FYI,the LocalStorage save in the database whitch path is
Library/WebKit/LocalStorage/
(UIWebview)Library/Caches/
(UIWebview)Library/WebKit/WebsiteData/LocalStorage/
(WKWebView)Then open the database,execute query
SELECT key,value FROM ItemTable
can getkey
andvalue
.The key is NSString,value is NSData,encode withNSUTF16LittleEndianStringEncoding
,convert to NSString with code:I don't think there is currently any native API for accessing the local storage but you could try to create a web view with some JavaScript that dumps the local storage to i.e. JSON.
Create a
UIWebView
that has aUIWebViewDelegate
delegate that implements thewebViewDidFinishLoad:
method and uses thestringByEvaluatingJavaScriptFromString:
method to trigger a dump.Something like this, first the page to load in the web view:
Then the finish load delegate method: