Contents

WKURLSchemeHandler

A protocol for loading resources with URL schemes that WebKit doesn’t handle.

Declaration

@MainActor protocol WKURLSchemeHandler : NSObjectProtocol

Overview

Adopt the WKURLSchemeHandler protocol in objects that handle custom URL schemes for your web content. Custom schemes let you integrate custom resource types into your web content, and you may define custom schemes for resources that your app requires. For example, you might use a custom scheme to integrate content that is available only on the user’s device, such as the user’s photos. Adopt this protocol in one of your app’s objects and register it using the setURLSchemeHandler(_:forURLScheme:) method of WKWebViewConfiguration.

When a web view encounters a resource that uses a custom scheme, it creates a WKURLSchemeTask object and passes it to the methods of your scheme handler object. Use the webView(_:start:) method to begin loading the resource. While your handler loads the object, the web view may call your handler’s webView(_:stop:) method to notify you that the resource is no longer needed.

Topics

Loading a Custom Resource

Responding to a Canceled Resource Request

See Also

Web data management