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

Shazron Abdullah commented on CB-7539:
--------------------------------------

Thanks Liming Xie, I like the idea. Here's what I'm thinking:

To use WKWebView as the default web engine, we need a local http server running 
(at least until Apple fixes this bug). This will *NOT* be embedded as part of 
Cordova, but is a plugin with "onload" = true in the feature tag.

This accomplishes two things:
1. Maintenance of the plugin is out of Cordova committer's hands, we don't have 
to be experts
2. Ability to swap (if need be) another http server. Not sure if this is that 
important

However Cordova still needs to discover the http server during startup. This 
can be achieved through Preferences, and a new protocol these http servers will 
need to implement (simple stuff).

I'm thinking:
{code}
<preference name="CordovaHttpServer" value="CorHttpd" /> <!-- the http server 
plugin feature name -->
{code}

CorHttpd will implement, say, CDVHttpServerProtocol My proposal:
{code}
- (void) startServer:(NSURL*)root; // we want a randomized port, return the 
serverUrl
- (void) stopServer;
- (NSURL*) serverUrl; // return the server url
- (void) setSessionKey:(NSString*)sessionKey; // not sure how this will work 
yet at all.
{code}

If preference UseWKWebView is true, we look for the CordovaHttpServer 
preference, now we know which plugin is the loaded http server. We check that 
it conforms to CDVHttpServerProtocol, then call startServer, passing in the www 
root (we need to pass in the exact html file to load), generate a UUID for the 
sessionKey, set the sessionKey, grab the serverUrl, and pass it to WKWebView.

If the CordovaHttpServer plugin is missing, we error out and prompt the user to 
install one, with a recommendation (in this case CorHttpd).


> [WKWebView][iOS 8] Use local webserver option to load local HTML file from www
> ------------------------------------------------------------------------------
>
>                 Key: CB-7539
>                 URL: https://issues.apache.org/jira/browse/CB-7539
>             Project: Apache Cordova
>          Issue Type: Sub-task
>          Components: iOS
>            Reporter: Shazron Abdullah
>            Priority: Blocker
>
> This workaround is because of this bug:
> http://www.openradar.me/radar?id=5839348817723392
> (filed with Apple of course also)
> I'm still hoping that Apple fixes this in iOS 8.1, but we should have this as 
> a contingency plan.
> Create this as an included plugin, so it can be extracted later if need be.
> We need to secure access to the local webserver, probably through a session 
> token in the header, since background apps can have access to the webserver. 
> The session token is passed down to the initially loaded local page specified 
> from the <content> tag in config.xml, and should be used in the cordova.exec 
> call. We would also need to implement local proxy support , see CB-7348
> This all sounds more complex than it needs to be than just loading a file url 
> -- wishing Apple would just fix this in iOS 8.1 instead.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to