Instance Method

add(_:name:)

Adds a script message handler.

Declaration

func add(_ scriptMessageHandler: WKScriptMessageHandler, name: String)

Parameters

scriptMessageHandler

The message handler to add.

name

The name of the message handler.

Discussion

Adding a script message handler with name name

causes the JavaScript function window.webkit.messageHandlers.name.postMessage(messageBody) to be defined in all frames in all web views that use the user content controller.