What This Example Demonstrates
- Initializing a
BridgeHostwith typed capability slots - Declaring document capture support via handler assignment
- Displaying a journey using
BridgeWebView - Observing bridge errors
Complete Source
How It Works
-
BridgeHost(hostVersion:)creates a host with typed capability slots. No separate configuration dictionary is needed. -
Setting a handler on
documentCapturedeclares the capability as supported. The handler usesawaitCompletion()to suspend until the UI layer callscomplete(). -
CameraDetector.check()detects camera hardware and permission state. ThepermissionStateis included in capability query responses. -
BridgeWebViewcreates aWKWebView, injects the bootstrap script, registers the message handler, attaches the WebView to the host, and loads the journey URL. -
Error observation —
host.lastErroris@Published, so the error banner appears and disappears reactively.
What Happens at Runtime
Required Info.plist Entries
For this minimal example, no special Info.plist entries are needed beyond the defaults. If your journey URL uses HTTP during development, add:Next Steps
- Two-Way Communication — Send events and handle requests
- Advanced Integration — Custom handlers, lifecycle, and error handling