1

I am working on WKWebView and want to support file downloading and displaying in Quick Look. Below is the format of html tag

< a href=https://abc/p/docs/DownloadTest.xlsx>DownloadTest.xlsx< /a>"

In Android: The above code is working fine in android. We have Download Listener in Webview. It will detect download and gives call back Android webview: download files like browsers do

In iOS: The first thing i would like to ask, is there any callback in WKWebView which identify download link from the same html or need to check manually in decidePolicyFor navigationAction delegate?

iOS_Developer
  • 495
  • 4
  • 20
  • Similar question asked: https://stackoverflow.com/questions/48903293/ios-wkwebview-handle-file-download?rq=1 – iOS_Developer Apr 03 '19 at 09:54
  • I'm thinking that you can check for the file type in decidePolicyFor. For instance, I can use AVAsset to load up the remote URL (navigationAction,request.url) and check isPlayable. If it is, I know I can invoke a media player instead of loading the page in WKWebView. You could potentially download the file and check the type as well so you can directly load it without downloading it when you present the content (in the case if the type is the one you want) I hope that this comment can inspire some ideas. –  Apr 03 '19 at 17:10
  • In iOS WKWebview, the issue is with the QuickLook (`x-apple-ql-id`). Each previewable format are converted into HTML by the built-in previewer and thats why for the formats like ppt, doc, pptx, etc. you will still get the mimetype `text/html` instead of the actual one. This is Bug because if you still debug in safari you will find the actual MimeType but, in WKWebView thats displaying the Mimetype `text/html` – Mrug May 25 '20 at 19:43

0 Answers0