WKWebView should have a method to send messages from native to JS

Originator:alpert
Number:rdar://17207002 Date Originated:2014-06-06
Status:Duplicate of 17152685 Resolved:
Product:iOS SDK Product Version:iOS 8, beta 1 (12a4265u)
Classification: Reproducible:
 
WKWebView supports "- addScriptMessageHandler:name:" on the WKUserContentController which allows creating a communication channel that allows sending messages from JS to the native side.

As far as I can tell, there's no method for doing the reverse: sending messages from native to JS. This would be useful for causing navigations or other changes in a web page in response to pressing a native button (for instance).

(See also http://stackoverflow.com/q/24049343/49485.)

WKWebViewPrivate has _runJavaScriptInMainFrame: which sounds like it provides the appropriate function, but it isn't documented or supported. Can this method be publicized or a similar one added?

Thanks.

Comments

Fixed in iOS 8 beta 3

Not in docs, but in the public header: evaluateJavaScript:completionHandler:


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!