<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKScriptMessageHandler/userContentController(_:didReceive:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(pl)WKScriptMessageHandler(im)userContentController:didReceiveScriptMessage:"
  },
  "title" : "userContentController(_:didReceive:)"
}
-->

# userContentController(_:didReceive:)

Tells the handler that a webpage sent a script message.

```
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage)
```

## Parameters

`userContentController`

The user content controller that delivered the message to your handler.

`message`

An object that contains the message details.

## Discussion

Use this method to respond to a message sent from the webpage’s JavaScript code. Use the message parameter to get the message contents and to determine the originating web view.

---

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)