Skip to content

WebViewContext

One WebView as one hook sees it, for the life of the WKWebView.

protocol WebViewContext : AnyObject

Overview

Call emit(_:_:) and ask(_:_:_:) from any thread, and the rest on the main thread, where configure, attach, the handlers and the answers run.

A context kept after the view closed does nothing.

A hook is on while its extension’s options are not null or false; HookExtension.options says what off means.

Values from JS arrive as Foundation’s JSON types: a number as NSNumber, an object as NSDictionary, an array as NSArray. In an ask’s answer and a handle(_:_:) handler’s arguments, null is nil at the top level and NSNull inside an array or object.

See Also

Native hooks guide