You need to change your Javascript (or inject Javascript code) to call postMessage()
function instead. Since you can only pass one parameter you can compose a JSON:
window.webkit.messageHandlers.mobile.postMessage({
"orderId": orderId,
"email": account.email,
"status": "ACCEPTED"
});
That way you can handle body
property of WKScriptMessage
like a dictionary, in Swift:
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
let dictionary = message.body as? [String: Any]
guard
let orderId = dictionary?["orderId"] as? Int,
let email = dictionary?["email"] as? String,
let status = dictionary?["status"] as? String
else { return }
delegate?.preScreenerFinished(orderId, email, status)
}
CLICK HERE to find out more related problems solutions.