0

I am using a WKWebView with Swift 3 to display content that I want to save the state of. (Not possible within IOS itself) See for Reference. One of my ideas was to clone the current state of the webview to a hidden webview, however according to the apple documentation there is no pre-commit function, however there is a policy function to call as shown below

    func webView(WKWebView, decidePolicyFor: WKNavigationAction, 
      decisionHandler: @escaping (WKNavigationActionPolicy) -> Void)
      //Decides whether to allow or cancel a navigation.

Overall I am looking to check a load request based on the URL before committing so I can do some action. Is this possible and what type of options do I have to accomplish this? Thank you!

Community
  • 1
  • 1
applecrusher
  • 5,508
  • 5
  • 39
  • 89

1 Answers1

0

There was no way that I discovered to do this, but let me tell you what I ended up doing.

On the JavaScript side I first prevented propagation and detected all whether the device was a WKWebView. If it was, I sent JavaScript over to Swift to tell it to open up in a new WKWebView. I put the WKWebView in the same container as the first one. I hide the other one, so I could go back to it eventually and showed this one.

applecrusher
  • 5,508
  • 5
  • 39
  • 89