I am using WKWebView with loadRequest method swizzled to set custom request (as it in tutorial like here
But when internal links followed, loadRequest not called, so in finish load I can get only request which was placed early exactly in loadRequest method, it is obvious.
Now I check in decidePolicyForNavigationAction if navigation action type is WKNavigationTypeLinkActivated and then set NSURLRequest to WKWebView request property directly.
The question is - how to intercept internal links was clicked to set WKWebView request custom property internally.
Just in case implementation in WKWebView category
- (void) setRequest: (NSURLRequest *) request
{
objc_setAssociatedObject(self, @selector(request), request, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
I have to NSURLRequest to be present in WKWebView and process it in didFinishNavigation logic.