I tried some other technique to debug this and get to the root of the issue, I decided to put window.webkit.messageHandlers.handlerOne.postMessage(... and window.webkit.messageHandlers.handlerTwo.postMessage(... inside an if conditional and check which is the object that is `undefined.
(function() {
addEventListener('mousedown', function() {
if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.handlerOne) {
window.webkit.messageHandlers.handlerOne.postMessage('WKUserScriptMouseDown');
}
}, true);
})();
After debugging this I found out that window.webkit.messageHandlers is the undefined object, which leads me to believe that webView.configuration.userContentController.add(handlerClass, name: "...") is broken on iOS 17.2 beta
hence messageHandlers is never defined, I'd appreciate to hear if this is happening to someone else with their apps.
Post
Replies
Boosts
Views
Activity
I tried removing the custom handlers and attempted this:
(function() {
addEventListener('mousedown', function() {
window.webkit.messageHandlers.postMessage('WKUserScriptMouseDown');
}, true);
})();
I would think this broadcast the message to all the handlers?? However now I get the error message:
TypeError: undefined is not an object (evaluating 'window.webkit.messageHandlers.postMessage')
My next attempt is to wrap this line into a (function() {})(); but if someone else has an idea or is facing similar issues with iOS beta 17.2 only it would be great to hear ideas