5

I have embedded a WebView in my macOS application and load a page in it. When users interact with the page, changes are stored in localStorage (as confirmed by making the same changes in Chrome), but it appears WebViews do not persist localStorage on macOS.

Earlier answers (years ago) indicate to use a private API which has since been removed entirely. Is there really no way at all to persist localStorage for a WebView in macOS? That seems crazy.

RealCasually
  • 3,593
  • 3
  • 27
  • 34
  • I should mention I do not own the site being displayed so I am unable to make any changes to it. It stores it's data in localStorage. – RealCasually Sep 01 '17 at 22:51

2 Answers2

-1

Since I'm getting downvoted I thought I should see if I could improve my answer. here. This question seems to have a solution: How do I enable Local Storage in my WebKit-based application?

Old answer that was not helpful:

The following thread has a workaround that may or may not solve your problem: Javascript/HTML Storage Options Under File Protocol (file://)

It suggests using window.name to store data across page reloads. It is not safe as the data is not isolated to your frame and could leak to other frames/tabs/domains but it may solve your problem.

Daniklad
  • 945
  • 8
  • 10
-1

You could always set up a simple CoreData store for the data changes and restore it to the WebView in ViewWillAppear.

And there is this solution as well.

Chris
  • 955
  • 15
  • 20