Type Method

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: ((Error?) -> Void)? = nil)

Parameters

messageName

A string that identifies the message.

toExtensionWithIdentifier

The bundle identifier for the app extension.

userInfo

Optional message content.

completionHandler

A completion handler called when the task completes.

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.