Contents

WKScriptMessage

An object that encapsulates a message sent by JavaScript code from a webpage.

Declaration

@MainActor class WKScriptMessage

Overview

Use a WKScriptMessage object to get details about a JavaScript message sent to a custom message handler in your app. You don’t create WKScriptMessage objects directly. When JavaScript code targets one of your app’s message handlers, the WKUserContentController object of the web view creates a WKScriptMessage object and delivers it to the message handler’s delegate method. Use the object you’re provided to process the message and provide an appropriate response.

For more information about handling script messages, see the WKScriptMessageHandler and WKScriptMessageHandlerWithReply protocols. For information about how to register message handlers, see the methods of WKUserContentController.

Topics

Getting the Message Contents

Getting Message-Related Information

Getting the Message Handler’s Name

See Also

Receiving Messages