dispatchMessage(withName:toExtensionWithIdentifier:userInfo:completionHandler:)
Sends a message to a Safari app extension, launching Safari if necessary.
Declaration
class func dispatchMessage(withName messageName: String, toExtensionWithIdentifier identifier: String, userInfo: [String : Any]? = nil, completionHandler: (@Sendable ((any Error)?) -> Void)? = nil)class func dispatchMessage(withName messageName: String, toExtensionWithIdentifier identifier: String, userInfo: [String : Any]? = nil) async throwsParameters
- 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.
Mentioned in
Discussion
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.