<!--
{
  "availability" : [
    "macOS: 10.12.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SafariServices",
  "identifier" : "/documentation/SafariServices/SFSafariPage/dispatchMessageToScript(withName:userInfo:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Safari Services"
    ],
    "preciseIdentifier" : "c:objc(cs)SFSafariPage(im)dispatchMessageToScriptWithName:userInfo:"
  },
  "title" : "dispatchMessageToScript(withName:userInfo:)"
}
-->

# dispatchMessageToScript(withName:userInfo:)

Dispatches a message from the app extension to the content script injected in this page.

```
func dispatchMessageToScript(withName messageName: String, userInfo: [String : Any]? = nil)
```

## Parameters

`messageName`

A string that identifies the message.

`userInfo`

An optional dictionary containing additional message content. If a dictionary is provided, values must conform to the W3C standard for safe passing of structured data, such as Boolean objects, numeric values, strings, and arrays.

---

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)