WKURLSchemeTask
An interface that WebKit uses to request custom resources from your app.
Declaration
protocol WKURLSchemeTask : NSObjectProtocolOverview
The WKURLSchemeTask protocol defines an interface that WebKit uses to request custom resources. You don’t adopt this interface in your own objects. Instead, WebKit creates objects that adopt this interface and delivers them to your custom scheme handlers — that is, objects that adopt the WKURLSchemeHandler protocol. You use the objects that WebKit provides to get information about the requested resources and load them. You also use those objects to report your progress back to WebKit.
When WebKit needs a custom scheme, it places an appropriate URL request in the task’s request property. Upon receiving the request, determine the size of the resource and call the didReceive(_:) method with an appropriate URL response object. Providing a response mirrors the behavior that a web server performs when it receives a request.
After you load some portion of the resource data, call the didReceive(_:) method to send it to WebKit. You may call that method multiple times to deliver data incrementally, or call it once with all of the data. After you finish delivering all of the data, call the didFinish() method. If an error occurs at any point during the load process, call didFailWithError(_:) to report it.