Now i'm using UIWebView
and with canInitWithRequest:
of NSURLProtocol
i can intercept all requests and do with it what I want.
In the new WKWebView
this method there isn't, and i not found something similar.
Has someone resolved this problem?
2 Answers
Answers 1
I am blindly taking guesses since I only have my windows computer with me. By reading the Apple Developer documentation here is information I gathered that might lead to some ideas on how to solve the question.
Based on WKWebView,
Set the delegate property to an object conforming to the WKUIDelegate protocol to track the loading of web content.
Also, I see we can set our navigationDelegate
with the,
weak var navigationDelegate: WKNavigationDelegate? { get set }
The methods of the WKNavigationDelegate protocol help you implement custom behaviors that are triggered during a web view's process of accepting, loading, and completing a navigation request.
Then after we create and set our custom WKNavigationDelegate, we would override some methods to intercept something we might be looking for. I found the Responding to Server Actions section of some interest since they receive a WKNavigation as parameter. Moreover, you might want to skim through WKNavigationAction and WKNavigationResponse see if there is perhaps something which might help us achieve our goal.
BTW, I am just giving some ideas on what to try so that we can solve this question, ideas which might be 100% wrong cause I have not tried them myself.
Answers 2
WKWebView doesn't support this function. Because WKWebView makes requests and renders content out-of-process, meaning your app does not hear the requests they make.
0 comments:
Post a Comment