I am the front-end js,. I need to use OC to call Android and ios to pass webSend 4 parameters, they do the sharing function, and then return to me whether the sharing is successful.
looked up the method on the Internet, but reported an error Cannot read property "messageHandlers" of undefined, Cannot read property" android" of undefined,. I don"t know where the problem is
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<button type="button" onclick="shareInformation()"></button>
</body>
<script>
function callback(data) {
//
}
function shareInformation() {
var lcon = {
title: document.title,
content: "",
url: window.location.href,
imageUrl: "https://www.baidu.com/",
cb: "callback"
}
window.webkit.messageHandlers.webSend.postMessage(lcon);
android.webSend(lcon);
}
</script>
</html>