-
Notifications
You must be signed in to change notification settings - Fork 333
Fix cordova-ios 6 issue with file:// requests being rejected #655
Conversation
b77d68c
to
7c26e5f
Compare
A couple of comments, as stated in the issues, UIWebView, is not only deprecated, its persona non grata. So the backwards comp in CodePush.m
that mentions UIWebView, is actualy a showstopper. New Apps with this code will be rejected by the App store. Doing a search, shows thats the CodePushReportingManager.m also has UIWebView code Both should be easy, to just cut? Here is the post from Apple, about not having UIWebView code: https://developer.apple.com/news/?id=12232019b |
Hi @sithwarrior yeah, we are aware about that. The changes in this PR are only to fix broken cordova 6 issues for customers. Removing of |
Hi @ruslan-bikkinin, thanks for this amazing PR. So you are aware that this PR does not allow us to submit new apps right? Only update existing apps for now. In my opinion, priority should be to support new (and by definition also existing) cordova-ios 6 apps with a new major version which removes all UIWebView mentions. People using cordova-ios 5 and below can still use older versions of this library. Unless this is significant more work for now and you just want to make the PR available for existing apps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 😄
Hi @Wouter33 good point. I'm going to start working on removing |
@ruslan-bikkinin I just tried installing this directly from the branch
It dosent work for me, it goes straight to the blank page. I've tried my poor objective C debugging skills, and it seems there is no good case for a Cordov-IOS 6 without the ionic WKWebView? (Cordova ios 6 has builtin WKwebview) The app is now loaded from file:// instead of the custom url scheme. This is actually even worse than before. |
@sithwarrior what's Cordova/Ionic version you are using? Could you please also share your |
@sithwarrior If you also could attach demo app on which you are experiencing the issue that would be very helpful! |
I just reproduced this on the codepush basic app, included with this project. Steps to reproduce: Setup custom URL scheme as recommended in config.xml on iOS remove the codepush plugin Install codepush from master, as the PR is now merged Build and run. The app is now served from file:// |
@sithwarrior I just tried to reproduce issue using the steps you provided and faced no problems: May be iOS version is involved. Do you use simulator or real device? What iOS version of device/simulator did you use? |
@ruslan-bikkinin Yes the app loads, but if you use Safari remote debugger, you can see that with the new changes in the PR, the app is now served from file:// That should not happen, as CORS will not work, in any way. edit: |
@sithwarrior could you please clarify what should I do in the basic app to start running into CORS issue you're describing? |
@ruslan-bikkinin hosting from file:// creates a lot of problems on ios, thats why the ionic wkwebview uses a built-in http server or custom url schemes, and thats why the new cordova-ios 6, also uses this feature.
The problem is most apparent, when you need to load additional files, such as json config files, local media etc. |
Im not a an objective C developer, so I dont no if it helps, but you can see here, how cordova-ios 6 loads the url scheme
|
Thanks a lot @sithwarrior, now I see the problem. I'm going to revisit this and fix as well. |
Related issue #624.
This PR is similar to #635 but makes a fix more clear way.
Problem
Starting with cordova-ios 6
UIWebView
is replaced withWKWebView
and alsoWKURLSchemeHandler
is introduced.If add these parameters to
config.xml
then
file://
requests are rejected byWKURLSchemeHandler
which causes app to become blank after applying CodePush update.There was already a fix for that in
CDVWKWebViewEngine+CodePush.m
but it was applied only for the case whenWKWebView
unless official support is added)This PR applies the fix for cordova-ios 6 as well.
Implementation specifics
loadRequest
andloadPluginRequest
methods was extracted fromCDVWKWebViewEngine+CodePush.m
into newWebViewShared
class. Now bothCodePush.m
andCDVWKWebViewEngine+CodePush.m
shares the same fix logic written in one place.