Skip to main content
This reference covers the iOS wiring for the WebView bridge. The dashboard generates a starting snippet with your agent’s real URL: open DistributeMobile App, turn on Enable Bridge Events, and select the Swift/UIKit tab. The snippet on this page also relays widget messages to the app and posts tars:init into the page, which the bridge requires.

Requirements

  • WKWebView from WebKit
  • A WKScriptMessageHandler registered under the name tarsbridge
  • Enable Bridge Events turned on for the agent

Snippet

Message wiring

The init script runs on the page load event, which can fire before the widget mounts. A tars:init posted that early is dropped and never answered. Resend tars:init until a tars:ready carrying capabilities arrives, because a repeat init after the handshake is ignored. The snippet above posts the init once, so add the resend before you ship it. Handle at least tars:navigate, tars:data, and tars:close: the three capabilities the bridge declares in its tars:ready reply to tars:init. Field-level payloads for every message are in the bridge events reference.