I have a WkWebView in an application developed to run in iOS 8 or above. In order for the browser's code to communicate with my app, it needs to execute javascript utilizing the webkit's messageHandlers, like this, where my handler's name is "NAME":
window.webkit.messageHandlers.NAME.postMessage('hello from javascript running in the hosted page!');
I've added code at the app like:
[wbConfig.userContentController addScriptMessageHandler:self name:@"NAME"];
_webView = [[WKWebView alloc] initWithFrame: [_webContainer bounds] configuration:wbConfig];
But when I run it in the simulator, window.webkit does not even exist. I'm baffled because nobody else has reported this issue. I must be doing something wrong?
Oh, with iOS 9 simulator, my WkWebView does not even seem to work. I've downloaded and am using the ios 8.4 simulator. Could that be the issue?