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

fix(ios): Allow loading local html files #693

Merged
merged 1 commit into from
May 16, 2020

Conversation

dpalou
Copy link
Contributor

@dpalou dpalou commented May 8, 2020

Platforms affected

iOS

Motivation and Context

Opening a local HTML file with InAppBrowser and UIWebView works fine, but the same code with WKWebView throws an error:

webView:didFailProvisionalNavigation - 1: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 1.)

This Pull request is meant to fix that. I'm not an iOS developer, so I'm not sure if the allowingReadAccessToURL param should be more flexible or even configurable by options, but the change seemed to work in my case.

I tried opening an issue in the tracker, but I couldn't select the Apache Cordova project when creating the issue, I guess I lack some permissions.

Description

I read that in WKWebView the function to load files is loadFileURL instead of loadRequest, so I'm using that function if the URL scheme is "file".

Testing

I've executed "npm run tests" and no error was displayed (no success message either, so I'm not 100% sure it worked).

I've tested this in our project but with the 3.2.0 version instead of master branch, so this should have a more intensive testing.

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@jcesarmobile
Copy link
Member

We use github issues now instead of JIRA, that's why you couldn't report the problem there.

Can you provide a sample app where the issue can be reproduced? I've tried loading a photo from file url and worked fine with existing code.

@dpalou
Copy link
Contributor Author

dpalou commented May 11, 2020

Hi jcesarmobile,

I created this project for you:

https://github.com/dpalou/iab-file-error

I included the node_modules and plugins in there, but not the platform. Just add the iOS platform, run the app and click the "Click me" button. I got the same error I described in the Pull Request, you can see the error in the Xcode console.

Thanks!

Copy link
Member

@jcesarmobile jcesarmobile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified that fix the html file loading and doesn't break loading image files (i.e, from camera plugin result), so merging, thanks for contributting!

@jcesarmobile jcesarmobile changed the title fix(ios): Allow loading local files with WKWebView fix(ios): Allow loading local html files May 16, 2020
@jcesarmobile jcesarmobile merged commit dcfe692 into apache:master May 16, 2020
@guycalledseven
Copy link

I've created pull request for this pull request that addresses additional limitations imposed to loading of local storage on iOS.

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

Successfully merging this pull request may close these issues.

None yet

3 participants