I'm trying to create a WKNavigationDelegate for a WKWebView but have been unable to call the decisionHandler
. Does anyone have any idea how to do this?
ObjC.registerSubclass({
name: "test",
methods: {
"webView:decidePolicyForNavigationAction:decisionHandler:": {
types: ["void", ["id", "id", "id"]],
implementation: function(wv, navigationAction, decisionHandler) {
decisionHandler($.WKNavigationActionPolicyAllow);
return;
}
}
}
});
var delegate = $['test'].alloc.init;
webView.navigationDelegate = delegate;
The code works up to the point where it prevents the navigation action but the decisionHandler
is not called!
In the console I get the log:
Completion handler passed to -[test webView:decidePolicyForNavigationAction:decisionHandler:] was not called
Changing the type from "id" to "block" or "function" doesn't work.