[ 
https://issues.apache.org/jira/browse/CB-6884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14038982#comment-14038982
 ] 

Shazron Abdullah edited comment on CB-6884 at 6/20/14 7:11 PM:
---------------------------------------------------------------

Some test results when testing under iOS 6 and iOS 7 which doesn't have a 
WKWebView -- the app doesn't crash (WKWebView is weak linked) but the view is 
not created (the app is blank white). This will not be a problem under a 
unified implementation (next steps) where we we will default to using the 
UIWebView instead. We need to change the CDVPlugin.webView property to be "id" 
and let the user coerce it into the appropriate object after testing it using 
isKindOfClass.

Other problems:
1. WKWebView whitelist use
2. CDVViewController switching use of UIWebView and WKWebView
3. WebView preferences from config.xml (both UI and WK)
4. WKWebView loadHTMLString use (prob upcoming in beta 3, stubbed out for now)
5. WKWebView evaluateScript use (prob upcoming in beta 3, simplified 
implementation for now)
6. JavaScript alert (and confirm I think) doesn't work - will have to hook up 
the UIDelegate to handle this in a native fashion


was (Author: shazron):
Some test results when testing under iOS 6 and iOS 7 which doesn't have a 
WKWebView -- the app doesn't crash (WKWebView is weak linked) but the view is 
not created (the app is blank white). This will not be a problem under a 
unified implementation (next steps) where we we will default to using the 
UIWebView instead. We need to change the CDVPlugin.webView property to be "id" 
and let the user coerce it into the appropriate object after testing it using 
isKindOfClass.

Other problems:
1. WKWebView whitelist use
2. CDVViewController switching use of UIWebView and WKWebView
3. WebView preferences from config.xml (both UI and WK)
4. WKWebView loadHTMLString use (prob upcoming in beta 3, stubbed out for now)
5. WKWebView evaluateScript use (prob upcoming in beta 3, simplified 
implementation for now)


> Support new Cordova bridge under iOS 8 WKWebView
> ------------------------------------------------
>
>                 Key: CB-6884
>                 URL: https://issues.apache.org/jira/browse/CB-6884
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: CordovaJS, iOS
>         Environment: iOS 8 beta 1
>            Reporter: Shazron Abdullah
>            Assignee: Shazron Abdullah
>             Fix For: 3.6.0
>
>
> https://developer.apple.com/library/prerelease/ios/releasenotes/General/RN-iOSSDK-8.0/index.html
> WKUserContentController - add a script message handler with name "cordova":
> https://developer.apple.com/library/prerelease/ios/documentation/WebKit/Reference/WKUserContentController_Ref/index.html#//apple_ref/swift/cl/WKUserContentController
> The WKUserContentController is associated with a WKWebViewConfiguration which 
> is initialized with a WKWebView.
> {code}
> WKUserContentController* userContentController = [[WKUserContentController 
> alloc] init];
> // scriptMessageHandler is the object that conforms to the 
> WKScriptMessageHandler protocol
> // see 
> https://developer.apple.com/library/prerelease/ios/documentation/WebKit/Reference/WKScriptMessageHandler_Ref/index.html#//apple_ref/swift/intf/WKScriptMessageHandler
> [userContentController addScriptMessageHandler:scriptMessageHandler 
> name:@"cordova"];
> {code}
> In JavaScript, you would call into Objective-C thus:
> {code}
> var command = { callbackId: "blabla23", service:"Camera", action: 
> "takePicture", actionArgs: [ 1, 2, 3 ] };
> window.webkit.messageHandlers.cordova.postMessage(command);
> {code}
> In the object that conforms to the WKScriptMessageHandler protocol:
> {code}
> - (void)userContentController:(WKUserContentController 
> *)userContentController   didReceiveScriptMessage:(WKScriptMessage *)message
> {
>     if (![message.name isEqualToString:@"cordova"]) {
>         return;
>     }
>     NSDictionary* command = message.body;
>     // TODO: get the callbackId, service, action, actionArgs keys and create 
> a CDVInvokedUrlCommand, and dispatch it
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to