<!--
{
  "availability" : [
    "macOS: 10.12.4 -"
  ],
  "documentType" : "symbol",
  "framework" : "SafariServices",
  "identifier" : "/documentation/SafariServices/SFSafariApplication/dispatchMessage(withName:toExtensionWithIdentifier:userInfo:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Safari Services"
    ],
    "preciseIdentifier" : "c:objc(cs)SFSafariApplication(cm)dispatchMessageWithName:toExtensionWithIdentifier:userInfo:completionHandler:"
  },
  "title" : "dispatchMessage(withName:toExtensionWithIdentifier:userInfo:completionHandler:)"
}
-->

# dispatchMessage(withName:toExtensionWithIdentifier:userInfo:completionHandler:)

Sends a message to a Safari app extension, launching Safari if necessary.

```
class func dispatchMessage(withName messageName: String, toExtensionWithIdentifier identifier: String, userInfo: [String : Any]? = nil, completionHandler: (@Sendable ((any Error)?) -> Void)? = nil)
```

## Parameters

`messageName`

A string that identifies the message.

`identifier`

The bundle identifier for the app extension.

`userInfo`

Optional message content.

`completionHandler`

A completion handler called when the task completes.

## Discussion

> Important:
> You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration:
> 
> ```swift
> class func dispatchMessage(withName messageName: String, toExtensionWithIdentifier identifier: String, userInfo: [String : Any]? = nil) async throws
> ```
> 
> For information about concurrency and asynchronous code in Swift, see <doc://com.apple.documentation/documentation/Swift/calling-objective-c-apis-asynchronously>.

This method may be called only from the app that contains your Safari app extension. If your extension is disabled, nothing happens. If it is enabled, the message is delivered to your app extension. If necessary, this call ensures that Safari is launched and that your extension is running before delivering the message.

> Note:
> The message is sent to the user’s default version of Safari. For example, if a user has selected [Safari Technology Preview](https://developer.apple.com/safari/technology-preview/) as the default version on their system, the preview version is launched to receive the message.

---

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)