Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What File Types are Supported by WKWebView?

UIWebView supports a whole list of file types, as detailed in this Apple Technical Q&A doc:

In addition to HTML content, UIWebView can display specific document types.

iPhone OS 2.2.1 supports the following document types:

Excel (.xls)
Keynote (.key.zip)
Numbers (.numbers.zip)
Pages (.pages.zip)
PDF (.pdf)
Powerpoint (.ppt)
Word (.doc)

iPhone OS 3.0 supports these additional document types:

Rich Text Format (.rtf)
Rich Text Format Directory (.rtfd.zip)
Keynote '09 (.key)
Numbers '09 (.numbers)
Pages '09 (.pages)

Which is great. These days however they generally advise that developers use WKWebView instead of UIWebView as it's faster and offers significant JavaScript performance improvements. This is great, except that I can't find a list of file types that are supported.

It does appear to support media files (such as Quicktime .mov files) which UIWebView did not, but now Word documents (.docx) do not seem to work. Is there a list of file formats that are supported by WKWebView?

like image 647
Matt Lacey Avatar asked Jan 28 '16 23:01

Matt Lacey


People also ask

How do I import an HTML file into WKWebView?

Load Local HTML File to a WKWebViewlet myUrl = myProjectBundle. url(forResource: "my-html-file", withExtension: "html")!

Is WKWebView deprecated?

Since then, we've recommended that you adopt WKWebView instead of UIWebView and WebView — both of which were formally deprecated. New apps containing these frameworks are no longer accepted by the App Store.

What is the difference between UIWebView and WKWebView?

Unlike UIWebView, which does not support server authentication challenges, WKWebView does. In practical terms, this means that when using WKWebView, you can enter site credentials for password-protected websites.

Is WKWebView the same as Safari?

WKWebView. WKWebView was introduced in iOS 8 allowing app developers to implement a web browsing interface similar to that of mobile Safari. This is due, in part, to the fact that WKWebView uses the Nitro Javascript engine, the same engine used by mobile Safari.


1 Answers

I had the same question. I lodged a Technical Support Incident with Apple and received this answer (21st Sep 2017):

  1. All Microsoft Documents are supported.
  2. All iWork documents are supported.
  3. If UIWebView would render a document type then WKWebView will as well.

On an iOS device running 10.3.3 and the Xcode 9.0 iOS 11.0 simulator, the above seems to work. I can display a range of MS Office documents (including docx, pptx, xlsx) as well as the UIWebView ones documented by Apple in QA 1630.

The above list is however lacking at least the various image formats, so it's clearly incomplete. If I get more information from Apple I'll update this answer...

(Bug report 17972625 requests WKWebView's documentation be updated to precisely specify what formats it does actually support, if you care to submit a duplicate to Apple Bug Reporter.)

like image 175
user2067021 Avatar answered Sep 19 '22 18:09

user2067021