WKWebView can request native capabilities like camera, NFC, and biometrics.
What GBGBridge enables
- Native capability access from web journeys: Web-based identity flows can request camera capture, NFC reads, and other device features through a standardized message protocol.
- Typed capability slots: Declare support for document capture and selfie capture by setting handlers on built-in typed slots. The SDK handles result encoding, busy rejection, and capability query responses automatically.
- Bidirectional messaging: Both the native host and the web content can send and receive structured messages, enabling real-time coordination.
- Capability negotiation with permission state: The web journey can query which native capabilities are available — including camera permission status — before attempting to use them, enabling graceful degradation across environments.
- Drop-in SwiftUI integration: A ready-made
BridgeWebViewcomponent handles WebView setup, script injection, and message routing with minimal boilerplate. Typed slots expose@Publishedproperties for reactive UI binding. - Extensible handler architecture: Register custom capability handlers to fulfill any request type the web journey might send, alongside or instead of typed slots.
Architecture at a glance
GBGBridge sits between your iOS app and the web journey, routing structured messages in both directions: The web journey sends structured JSON messages to the native host viawindow.webkit.messageHandlers.gbgBridge.postMessage(). The BridgeHost decodes each message, routes requests to registered capability handlers, and sends responses back by evaluating JavaScript on the WebView via window.GBGBridge.receive().
Quick start
The minimum integration is aBridgeHost, a BridgeWebView pointed at your journey URL, and a handler set on the document-capture slot:
BridgeWebView handles WebView creation, bootstrap script injection, and message handler registration. Capability query responses — including permission state — are built automatically from the slots you configure.