2
votes

TL;DR - I want to download a .csv and other files from a link, and present a UIActivityViewController.

I'm working in an app with lots of WKWebViews. In one of the delegate methods, decidePolicyForNavigationAction:, the available URL is a URL compatible with URLRequests, and I can download just fine from it. (navigationAction.request.url)

In another delegate method decidePolicyForNavigationResponse: the response's url (navigationResponse.response.url) identifies as part of Apple's QuickLook framework scheme, and contains this: x-apple-ql-magic. I was trying to use a QLPreviewController, but couldn't populate the dataSource with a remote file I wanted to download.

My goal is: When a link points to a downloadable file, like a .csv or PDF, give a user the option to share this file via UIActivityViewController.

How can I download remote files from this scheme: x-apple-ql-magic?

1

1 Answers

3
votes

You can’t. When WKWebView previews a file such as CSV, it is internally converted to HTML by Quick Look to be rendered by WebKit. The x-apple URL is the URL of the converted content. It should not be exposed to you, you should be seeing the original URL instead, please file a bug.

Why do you want to use the response delegate in the first place instead of the delegate at link tap time?