userContentController(_:didReceive:replyHandler:)
Tells the handler that a webpage sent a script message that included a reply.
Declaration
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage, replyHandler: @escaping @MainActor @Sendable (Any?, String?) -> Void)func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) async -> (Any?, String?)Parameters
- userContentController:
The user content controller that delivered the message to your handler.
- message:
An object that contains the message details.
- replyHandler:
A reply handler block to execute with the response to send back to the webpage. This block has no return value and takes the following parameters:
Discussion
Use this method to handle a message from the webpage and provide an appropriate response.