1

Everything is in the title : I'd like to init a WKWebVIew with a pre-loaded history.

Actually, my ultimate goal is to save the history of my WKWebView so when a user closes the app and re-opens it, he/she can get his/her web view back ( with the same history ).

Is there a way to do that ? At first, I wanted to save the backForwardList of my WKWebView but it's actually impossible to set it when initialising the web view, as it is a get-only property.

I also thought about saving all the URLs and then reloading them one by one but I'm pretty sure there's an easier way to accomplish that. I don't know how Google and Apple do with Chrome and Safari.

Randy
  • 4,335
  • 3
  • 30
  • 64
  • Even a JS solution such as https://stackoverflow.com/a/37661900/804616 is not possible due to same-origin policy of the [History.pushState() API](https://developer.mozilla.org/en-US/docs/Web/API/History/pushState). – trss Sep 19 '20 at 17:52
  • So it looks like implementing one's own navigation stack as mentioned at https://stackoverflow.com/a/34035243/804616 is the way to go. Still wondering how an API feature could be so limited in nature. Makes me think there must be a way! :) – trss Sep 19 '20 at 17:54
  • The solution at https://stackoverflow.com/a/31538352/804616 looks complicated but it's by a Mozilla developer so they must have done their research and this might very well be the best option available. – trss Sep 25 '20 at 16:55
  • The solution at https://stackoverflow.com/a/31468755/804616 looks simpler but may impact start-up time. – trss Sep 25 '20 at 16:56
  • Posted the above two comments as an answer but it got deleted by moderation. Suggestions were to flag this question as a duplicate and to quote the contents of the link so they're available even if the links are gone. But this question is more accurately phrased compared to the other question so I won't flag this as a duplicate. And I am unable to undelete after editing the answer to quote the contents because it was deleted by a moderator which can't be undone apparently. – trss Sep 25 '20 at 17:00

0 Answers0