CXR-L(EN)
cxr-l-sdk · v1.0.1 · snapshot 2026-05-13· ↗ source

Connection and Session

iOS: Connection and Session

Scenario

After authentication succeeds, use the singleton CxrClient.shared to establish the collaboration link with the glasses. Unlike Android, which explicitly constructs CXRLink, iOS typically distinguishes modes such as customView / customApp via initialization options and uses Combine event streams to observe audio, Custom View runtime state, etc.

Prerequisites

  • “02-Authentication” has succeeded and auth is in an authorized state.
  1. Configure client initialization options (mode, target package name, page name, etc.), following RGCxrClientInitializationOptions and the current SDK headers.
  2. Hold let client = CxrClient.shared in your business UIViewController (or inject a wrapper).
  3. Subscribe to:
    • auth.statePublisher: continuously watch for logout/expiration.
    • audioEventPublisher: audio link and data chunks.
    • customViewRunningEventPublisher: whether the Custom View is running.
  4. Only after glasses-side scene building (the Custom View is running, or the Custom App has been launched according to SDK requirements) should you enable Audio, Photo, and Custom Command; do not enable them at “authenticated + link ready” alone.

Capability matrix (summary)

StateAudioPhotoCustom Command
Not authenticatedNoNoNo
Authenticated, link not readyNoNoNo
Authenticated, link ready, scene not builtNoNoNo
Authenticated, link ready, customView and view runningYesYesNo
Authenticated, link ready, customApp and app launchedYesYesYes

“Scene built” should be judged using customViewRunningEventPublisher, app foreground/background, page-name events, etc. (follow the current RGCxrClient version). Strict prerequisites for Custom Command are described in “Custom Command”.

Sample entry points (typical)

The main view controller (commonly named ViewController.swift in docs) demonstrates capability buttons and event bindings. Replace it with the actual file names in ios_cxr_l_sample.

Marcin Miazga