[ad_1]
// each time I load any URL in my webview , then this callbackhadler should work when referred to as by javascript in loaded web site/URL, but it surely would not get referred to as, in my case, I m engaged on fee portal and after success/failed fee web site should name this callbackHandler
// view did load
override func viewDidLoad() {
tremendous.viewDidLoad()
let contentController = WKUserContentController()
contentController.add(self, identify: "callbackHandler")
contentController.add(self, contentWorld: .defaultClient, identify:
"callbackHandler")
let config = WKWebViewConfiguration()
config.ignoresViewportScaleLimits = true
config.userContentController = contentController
config.preferences.javaScriptCanOpenWindowsAutomatically = true
config.defaultWebpagePreferences.allowsContentJavaScript = true
self.webView = WKWebView( body: .zero, configuration: config)
}
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {// edit: modified enjoyable to func
if (message.identify == "callbackHandler"){
print("with boby mesage (message.physique)")
}
}
right here is the article supplied by fee firm which instructed this methodology within the first place,
userContentController by no means referred to as again from JS injection
[ad_2]
