<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKURLSchemeTask",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(pl)WKURLSchemeTask"
  },
  "title" : "WKURLSchemeTask"
}
-->

# WKURLSchemeTask

An interface that WebKit uses to request custom resources from your app.

```
protocol WKURLSchemeTask : NSObjectProtocol
```

## Overview

The [`WKURLSchemeTask`](/documentation/WebKit/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`](/documentation/WebKit/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`](/documentation/WebKit/WKURLSchemeTask/request) property. Upon receiving the request, determine the size of the resource and call the [`didReceive(_:)`](/documentation/WebKit/WKURLSchemeTask/didReceive(_:)-2u23r) 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(_:)`](/documentation/WebKit/WKURLSchemeTask/didReceive(_:)-8t5f8) 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()`](/documentation/WebKit/WKURLSchemeTask/didFinish()) method. If an error occurs at any point during the load process, call [`didFailWithError(_:)`](/documentation/WebKit/WKURLSchemeTask/didFailWithError(_:)) to report it.

## Topics

### Getting the URL of the Requested Resource

[`request`](/documentation/WebKit/WKURLSchemeTask/request)

Information about the resource to load.

### Reporting Progress Back to WebKit

[`didReceive(_:)`](/documentation/WebKit/WKURLSchemeTask/didReceive(_:)-2u23r)

Returns a URL response to WebKit with information about the requested resource.

[`didReceive(_:)`](/documentation/WebKit/WKURLSchemeTask/didReceive(_:)-8t5f8)

Sends some or all of the resource data to WebKit.

[`didFinish()`](/documentation/WebKit/WKURLSchemeTask/didFinish())

Signals the successful completion of the task.

### Reporting an Error to WebKit

[`didFailWithError(_:)`](/documentation/WebKit/WKURLSchemeTask/didFailWithError(_:))

Completes the task and reports the specified error back to WebKit.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)