Protocols

The following protocols are available globally.

  • A WebApp is an HTTP[S]-accessible location and a string identifier for logging. Optionally, it can also:

    • Store a reference to the WKWebView that hosts it
    • Provide a WKWebViewConfiguration
    • Provide a WKWebViewNavigationDelegate
    • Listen to webkit.messageHandlers[name].postMessage(body) calls

    To support these features, have a look at the other protocols starting with WebApp*.

    Conceptually, a WebApp represents your web application in native app code. It has sole responsibility for calling JavaScript in the page and receiving messages. A common pattern is to define a delegate and pass on messages as calls to the delegate.

    Simplest possible web app:

    class SimplestExampleWebApp: WebApp {
        let appIdentifier = "google"
        let initialURL = NSURL(string: "https://google.com")!
    }
    
    See more

    Declaration

    Swift

    public protocol WebApp
  • Add conformance to this protocol if your WebApp provides a WKWebViewConfiguration.

    See more

    Declaration

    Swift

    public protocol WebAppConfiguring
  • Add conformance to this protocol if your WebApp provides WKNavigationDelegate.

    See more

    Declaration

    Swift

    public protocol WebAppNavigating
  • Add conformance to this protocol if your WebApp would like a reference to the WKWebView it runs in.

    See more

    Declaration

    Swift

    public protocol WebAppWebViewReferencing
  • Add conformance to this protocol if your WebApp would like to listen to calls to webkit.messageHandlers[name].postMessage().

    See more

    Declaration

    Swift

    public protocol WebAppMessageHandling