Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support serving local content with WKURLSchemeHandler #415

Closed
AshleyScirra opened this issue Sep 19, 2018 · 6 comments · Fixed by #781
Closed

Support serving local content with WKURLSchemeHandler #415

AshleyScirra opened this issue Sep 19, 2018 · 6 comments · Fixed by #781
Milestone

Comments

@AshleyScirra
Copy link

Ref: https://bugs.webkit.org/show_bug.cgi?id=154916#c17

Cordova apps tend to serve local content. On iOS with WKWebView, this causes severe issues with many features, such as the complete inability to XMLHttpRequest or fetch local files due to strict security restrictions. Apps can resort to cordova-plugin-file, but this forces them to write different code to handle iOS, defeating the purpose of Cordova to allow the same code to run everywhere.

According to an Apple engineer, apps ought to be using WKURLSchemeHandler instead: https://developer.apple.com/documentation/webkit/wkurlschemehandler

Please consider officially supporting this in Cordova on iOS.

@dpogue
Copy link
Member

dpogue commented Sep 19, 2018

One challenge is that WKURLSchemeHandler is only available on iOS 11 and up, and Cordova currently supports as far back as iOS 9.

@AshleyScirra
Copy link
Author

AshleyScirra commented Sep 19, 2018

That is indeed an annoying compatibility quirk, but Apple's data shows that 85% of devices are already on iOS 11+. So I think for some apps it will be acceptable to only support iOS 11+ with WKURLSchemeHandler. Also Apple have officially stated that UIWebView is deprecated now and so more apps will be needing to migrate to WKWebView and running in to this exact problem.

@janpio
Copy link
Member

janpio commented Sep 19, 2018

We are aware of that, @dpogue just stated one of the challenges an implementation of this will have.

Do you have further input how exactly such an implementation could look like for cordova-ios (or cordova-plugin-wkwebview-engine, this is only relevant there, correct?)?

@guirip
Copy link

guirip commented Sep 26, 2018

Currently at Mobile-Spot we plan on using :

  • UI webview for iOS 11 and below
  • WK webview + custom url scheme for iOS12 and above

Today we are able to build an app for iOS 10 that uses WK webview, and this app handles the custom url scheme only if it is available in the API of the running device:

- (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)task
API_AVAILABLE(ios(11.0)){
    ...

The downside is that we have to manually edit CDVWKWebViewEngine.h and CDVWKWebViewEngine.m.

We also have to include UI webview / WK webview switch on startup which seems more difficult.

@jcesarmobile
Copy link
Member

iOS 9 is going away in next major release.
We officially only support current an previous iOS versions, so we could drop iOS 10 if we wanted to, but that will definitely piss users off.
As far as I remember, the only time we dropped support so soon was on cordova-ios 4.4.0 where we dropped support for iOS 8 by the end of 2016. (but was not really released until April 2017)

@sartrey
Copy link

sartrey commented Jun 4, 2019

WKURLSchemeHandler raised a lot of crash in our apps ( not cordova ).
And HTTPS main document can not load custom scheme resources.
Any idea to solve this two problems?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants