var MyNavigationDelegate = objc.newClass(
"MyNavigationDelegate",
"NSObject",
["WKNavigationDelegate"],
{
webViewDecidePolicyForNavigationActionDecisionHandler: function (
wv,
na,
decisionHandler
) {
voltmx.print(">>>>webViewDecidePolicyForNavigationActionDecisionHandler Start");
decisionHandler(WKNavigationActionPolicyAllow);
voltmx.print(">>>>webViewDecidePolicyForNavigationActionDecisionHandler End");
},
}
);
var delegate = MyNavigationDelegate.alloc().jsinit();
webView.navigationDelegate = delegate;
I set WKNavigationDelegate for WKWebView in my Project just like above. But when the code processing, my app crashed due to decisionHandler is instance of the NSBlock and it can not be executed like the code above. When running above code showing the follow errorMessage
TypeError: decisionHandler is not a function. (In ‘decisionHandler(WKNavigationActionPolicyAllow)’, ‘decisionHandler’ is an instance of NSBlock)
The code bellow is Objective-C code. Does anyone know what's the correct way to execute decisionHandler in NFI programing. Thanks
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
decisionHandler(WKNavigationActionPolicyAllow);
}