UAJavaScriptCommandDelegate

Objective-C

@protocol UAJavaScriptCommandDelegate <NSObject>

Swift

protocol JavaScriptCommandDelegate : NSObjectProtocol

A standard protocol for handling commands from the native brige.

  • Delegates must implement this method. Implementations take a model object representing the JavaScript command which includes the command name, an array of string arguments, and a dictionary of key-value pairs (all strings).

    If the passed command name is not one the delegate responds to return NO. If the command is handled, return YES and the command will not be handled by another delegate.

    To pass information to the delegate from a webview, insert links with a “uairship” scheme, args in the path and key-value option pairs in the query string. The host portion of the URL is treated as the command name.

    The basic URL format: uairship://command-name/?

    For example, to invoke a command named “foo”, and pass in three args (arg1, arg2 and arg3) and three key-value options {option1:one, option2:two, option3:three}:

    uairship://foo/arg1/arg2/arg3?option1=one&option2=two&option3=three *

    Declaration

    Objective-C

    - (BOOL)performCommand:(nonnull UAJavaScriptCommand *)command
                   webView:(nonnull WKWebView *)webView;

    Swift

    func perform(_ command: UAJavaScriptCommand, webView: WKWebView) -> Bool

    Parameters

    command

    An instance of UAJavaScriptCommand

    webView

    The web view.

    Return Value

    YES if the command was handled, otherwise NO.