Accessing UIWebView local storage data from native iPhone app

前端 未结 1 1380
南方客
南方客 2021-02-15 16:43

I\'m writing a native iPhone app that contains a UIWebView component. This component accesses an internet webapp and the webapp stores data offline using HTML5 local storage.

1条回答
  •  情深已故
    2021-02-15 16:47

    I was looking to do something similar to this. In short, the DOM and all elements are not directly accessible. However, you can hack things up to get at the data. What you have to do is inject your own javascript into the downloaded webpage. Then evaluate the results.

    This page shows the mechanism for doing it:

    http://iphoneincubator.com/blog/windows-views/how-to-inject-javascript-functions-into-a-uiwebview

    Then you just need to know the name of the database and create some javascript to return the values in a JSON string. Use a cocoa JSON parser to create objects from that string that you can use in your native app.

    0 讨论(0)
提交回复
热议问题