WKWebView does not support custom URL protocols

Originator:green
Number:rdar://18492325 Date Originated:Sept 29, 2014
Status:Duplicate Resolved:
Product:iOS SDK Product Version:8.0
Classification:Enhancement Reproducible:
 
Summary:
The new WebKit framework does not support subclasses of NSURLProtocol to intercept URL requests. This includes custom URL schemes used by the application.

It is possible to enable this feature within an app by calling +[WKBrowsingContextController registerSchemeForCustomProtocol:], but it is private API (and deprecated according to WebKit's project organizer). This behaviour should be available as part of the public API.

Steps to Reproduce:
Download and run the attached Xcode project. It will fail with the error "failed provisional navigation with error: Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" "

Expected Results:
The subclass of NSURLProtocol is asked if it wants to handle requests made by the webview in it's -[NSURLProtocol canInitWithRequest:] method.

Actual Results:
The subclass of NSURLProtocol is not called.

Version:
iOS 8.0 SDK

Notes:
Our app uses a custom URL scheme to do on-the-fly decryption of local assets. It is critical that we are able to decrypt the assets if we are to migrate our app from UIWebView to WKWebView.

Configuration:
iOS 8.0 simulator with Xcode 6.0

Attachments:
'WebViewCustomProtocol.zip' was successfully uploaded.

Comments

Steps to Reproduce without attachment

Here's a basic steps to reproduce for anyone else who submits this to Apple... which I would strongly encourage you to do, since for those of us who have relied on this functionality, losing it means we cannot migrate to WKWebView and its excellent speed improvements!

Steps to Reproduce: 1. Create an NSURLProtocol subclass and call [NSURLProtocol registerClass:[MyNSURLProtocolSubclass class]] 2. Create a WKWebView 3. MyNSURLProtocolSubclass methods never get called, whereas with a UIWebView they do

By karmelapple at Nov. 13, 2014, 3:49 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!