public interface WKScriptMessageHandlerWithReply
| Modifier and Type | Interface and Description |
|---|---|
static interface |
WKScriptMessageHandlerWithReply.Block_userContentControllerDidReceiveScriptMessageReplyHandler |
| Modifier and Type | Method and Description |
|---|---|
void |
userContentControllerDidReceiveScriptMessageReplyHandler(WKUserContentController userContentController,
WKScriptMessage message,
WKScriptMessageHandlerWithReply.Block_userContentControllerDidReceiveScriptMessageReplyHandler replyHandler)
Invoked when a script message is received from a webpage.
|
void userContentControllerDidReceiveScriptMessageReplyHandler(WKUserContentController userContentController, WKScriptMessage message, WKScriptMessageHandlerWithReply.Block_userContentControllerDidReceiveScriptMessageReplyHandler replyHandler)
When the JavaScript running in your application's web content called window.webkit.messageHandlers.
Passing a non-nil NSString value to the second parameter of the replyHandler signals an error.
No matter what value you pass to the first parameter of the replyHandler,
the Promise will be rejected with a JavaScript error object whose message property is set to that errorMessage string.
If the second parameter to the replyHandler is nil, the first argument will be serialized into its JavaScript equivalent and the Promise will be fulfilled with the resulting value.
If the first argument is nil then the Promise will be resolved with a JavaScript value of "undefined"
Allowed non-nil result types are:
NSNumber, NSNull, NSString, NSDate, NSArray, and NSDictionary.
Any NSArray or NSDictionary containers can only contain objects of those types.
The replyHandler can be called at most once.
If the replyHandler is deallocated before it is called, the Promise will be rejected with a JavaScript Error object
with an appropriate message indicating the handler was never called.
Example:
With a WKScriptMessageHandlerWithReply object installed with the name "testHandler", consider the following JavaScript:
userContentController - The user content controller invoking the delegate method.message - The script message received.replyHandler - A block to be called with the result of processing the message.