> For the complete documentation index, see [llms.txt](https://www.openclawbook.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.openclawbook.xyz/en/ch36-native-client-apps/36.2-ios-node-app.md). Agents can also search and read this documentation through its [MCP server](https://www.openclawbook.xyz/~gitbook/mcp).

# 36.2 iOS Node Application

> **Generated by**: Claude Opus 4.6 (initial draft) / Claude Opus 5 (`v2026.3.9` revision) **Token usage**: Input \~180k tokens, Output \~5k tokens (this section) **Source baseline**: `v2026.3.9` (`v2026.3.8-170-g665f67726`)

***

The OpenClaw iOS application differs fundamentally from the macOS application: the macOS app is a **control plane** (operator), while the iOS app is a **node**. A node does not run a Gateway; instead, it connects to a Gateway instance on the local network and exposes iPhone/iPad hardware capabilities (camera, screen, microphone, location) for use by AI agents.

## 36.2.1 Bonjour Pairing

### Service Discovery

The first task of the iOS application after launch is to find a Gateway on the local network. This is accomplished through Apple's **Bonjour** (mDNS/DNS-SD) protocol:

```swift
// apps/ios/Sources/Gateway/GatewayConnectionController.swift
@MainActor
@Observable
final class GatewayConnectionController {
    private let discovery = GatewayDiscoveryModel()
    private(set) var gateways: [GatewayDiscoveryModel.DiscoveredGateway] = []
    
    init(appModel: NodeAppModel, startDiscovery: Bool = true) {
        GatewaySettingsStore.bootstrapPersistence()
        self.updateFromDiscovery()
        self.observeDiscovery()
        if startDiscovery { self.discovery.start() }
    }
    
    // Scene lifecycle awareness
    func setScenePhase(_ phase: ScenePhase) {
        switch phase {
        case .background:  self.discovery.stop()   // Stop discovery in background
        case .active, .inactive: self.discovery.start()
        }
    }
}
```

> **Sidebar — Bonjour (mDNS/DNS-SD)**
>
> Bonjour is Apple's implementation of two IETF standards: mDNS (Multicast DNS, RFC 6762) and DNS-SD (DNS-based Service Discovery, RFC 6763). Devices on a local network broadcast and discover services via UDP multicast (224.0.0.251:5353) without requiring a central DNS server. For example, a Gateway broadcasts an `_openclaw._tcp` service, and the iOS app discovers it via `NWBrowser` and obtains the IP and port.

After discovering a Gateway, the user can choose to connect. Connection parameters include host address, port, TLS configuration, and authentication credentials:

```swift
func connect(_ gateway: DiscoveredGateway) async {
    let host = resolveGatewayHost(gateway)
    let port = gateway.gatewayPort ?? 18789
    let tlsParams = resolveDiscoveredTLSParams(gateway: gateway)
    let url = buildGatewayURL(host: host, port: port, useTLS: tlsParams?.required == true)
    // Connect to Gateway via WebSocket with role "node"
    startAutoConnect(url: url, tls: tlsParams, token: token, password: password)
}
```

### Application Entry Point

The iOS application's entry point is very simple:

```swift
// apps/ios/Sources/OpenClawApp.swift
@main
struct OpenClawApp: App {
    @State private var appModel: NodeAppModel
    @State private var gatewayController: GatewayConnectionController

    var body: some Scene {
        WindowGroup {
            RootCanvas()
                .environment(appModel)
                .environment(appModel.voiceWake)
                .environment(gatewayController)
                .onOpenURL { url in
                    Task { await appModel.handleDeepLink(url: url) }
                }
                .onChange(of: scenePhase) { _, newValue in
                    appModel.setScenePhase(newValue)
                    gatewayController.setScenePhase(newValue)
                }
        }
    }
}
```

`NodeAppModel` is the core state model of the application, managing sessions with the Gateway, device capabilities, voice wake, and more.

## 36.2.2 Canvas Surface

The main interface of the iOS application is a **Canvas surface**—not just a chat interface, but a "canvas" that AI agents can directly manipulate. Agents can send Canvas commands to control interface content, enabling capabilities such as displaying charts, animations, and interactive controls.

Source code structure:

```
apps/ios/Sources/
├── RootCanvas.swift        # Main Canvas view
├── Camera/                 # Camera capability
├── Screen/                 # Screen recording capability
├── Voice/                  # Voice capability
├── Location/               # Location capability
├── Chat/                   # Chat interface
├── Gateway/                # Connection management
├── Model/                  # Data models
├── Settings/               # Settings interface
├── Status/                 # Status display
└── SessionKey.swift        # Session key management
```

Canvas commands are defined by the shared library `OpenClawKit` (see Section 36.4), including DOM operations, file display, A2UI (Agent-to-UI) actions, and more.

## 36.2.3 Voice Wake / Talk Mode

The iOS node also supports voice wake and conversation mode, implemented similarly to macOS (shared from `OpenClawKit`), but with the following adaptations:

1. **Background limitations**: iOS does not allow applications to run audio capture indefinitely in the background. Voice wake pauses when the app enters the background (`setScenePhase(.background)` → stop discovery and recording)
2. **Audio session management**: Requires proper configuration of `AVAudioSession` category and mode to coexist peacefully with system audio (such as phone calls and music)
3. **Permission model**: iOS permission prompts are one-time—if the user denies microphone permission, they can only be guided to System Settings to enable it manually

## 36.2.4 Camera and Screen Recording

The unique value of the iOS node lies in exposing mobile device sensors to AI agents:

**Camera** (`Camera/`): Agents can request photos or real-time video frames for visual analysis. Camera capability is implemented via `AVCaptureSession`.

**Screen Recording** (`Screen/`): Agents can request screenshots or recordings. iOS uses the `ReplayKit` framework to provide screen content capture.

These capabilities are declared via the `caps` (capabilities) field when connecting to the Gateway:

```swift
// apps/shared/OpenClawKit/Sources/OpenClawKit/Capabilities.swift
public enum OpenClawCapability: String, Codable, Sendable {
    case canvas         // Canvas manipulation capability
    case camera         // Camera
    case screen         // Screen recording
    case voiceWake      // Voice wake
    case location       // Location information
}
```

The Gateway decides which tools can be used based on the capabilities declared by the node—for example, photo-taking tools can only be called by agents when a node with `camera` capability is connected.

***

## Summary of This Section

1. **The iOS application is a "node" role**, not running a Gateway but discovering and connecting to a Gateway instance on the local network via Bonjour.
2. **Service discovery** is based on mDNS/DNS-SD protocol, with the app automatically starting and stopping discovery based on scene lifecycle (foreground/background).
3. **Canvas surface** is the main interface where AI agents can directly manipulate interface content through commands.
4. **Voice wake** is shared from OpenClawKit but subject to iOS background execution limitations.
5. **Camera and screen recording** are core hardware capabilities of the node, declared via capabilities to let the Gateway know which tools are available.
