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

Shazron Abdullah commented on CB-6884:
--------------------------------------

Progress report.

The latest code in my branch uses @import instead of #import for WebKit, which 
doesn't require us to list the framework in the project explicitly. 

This gives us a true Xcode 5 / 6 compile solution, so we can have the same code 
working in either IDE version (thus different base SDKs of 7 and 8). HOWEVER 
there is a bug in Xcode (was there since 5) where if you do an @import for a 
framework, it won't link if your Deployment Target OS version does not also 
include the framework itself, when compiling for the Simulator. For example, if 
you @import WebKit, and build for the Simulator, your Deployment Target MUST be 
iOS 8, since only iOS 8 includes the WebKit framework (this is problematic if 
you want to support previous iOS versions, but see below).

The workaround is, this bug does not appear if you build for a device. To make 
it work for the Simulator, you will have to explicitly add the framework in 
Build Phases -> Link Binary with Libraries, but then you lose being able to 
switch using the project file easily between Xcode 5 and 6. This is not a 
problem if you want to stick to 6 only of course.

The other issues listed in my previous comment are still outstanding.


> 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