---
title: "userContentController(_:didReceive:replyHandler:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/wkscriptmessagehandlerwithreply/usercontentcontroller(_:didreceive:replyhandler:)"
---

# userContentController(_:didReceive:replyHandler:)

Tells the handler that a webpage sent a script message that included a reply.

## Declaration

```swift
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage, replyHandler: @escaping @MainActor @Sendable (Any?, String?) -> Void)
```

```swift
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) async -> (Any?, String?)
```

## Parameters

- `userContentController`: The user content controller that delivered the message to your handler.
- `message`: An object that contains the message details.
- `replyHandler`: A reply handler block to execute with the response to send back to the webpage. This block has no return value and takes the following parameters:

## Discussion

Discussion Use this method to handle a message from the webpage and provide an appropriate response.

## See Also

### Receiving Messages

- [WKScriptMessage](webkit/wkscriptmessage.md)
