CXR-L(EN)
CXR-L(EN)
IntroductionQuick StartDevelopment Flow & State-MachineTerms and Abbreviations
Feature Development
Version HistoryAndroid
iOS
cxr-l-sdk · v1.0.1 · snapshot 2026-05-13· ↗ source
Custom Commands
iOS: Custom Command
Scenario
Send business custom messages (command + binary payload) between the phone and the glasses-side app. The iOS SDK provides sendCustomCmd and subscription for uplink notify from the glasses. It is recommended to use this only in customApp mode (equivalent to Android CUSTOMAPP).
Prerequisites
- A customApp session is established and the glasses-side scene is built (for example,
openApphas succeeded and the app is interactive / at the agreedpageNamescene; see SDK release notes). Do not send custom commands when only the link is up but the app has not been launched. - The glasses-side APK implements the agreed cmd / subCmd / payload protocol and replies with a response for paths that require callbacks (otherwise the callback overload may not receive results).
Phone → Glasses
func sendCustomCmd(cmd: String, payload: Data?)
cmd: command name string.payload: optional binary data (the transport may encode as Base64, handled by the SDK).
Overload with completion callback:
func sendCustomCmd(cmd: String, payload: Data?, callback: ((_ success: Bool, _ payload: Data?, _ errorCode: Int32?, _ errorMsg: String?) -> Void)?)
Constraints
- Do not misuse the send API under a customView session; aligned with the product constraint that
sendCustomCmdis not allowed under AndroidCUSTOMVIEW. - Sending frequency and payload size must match the glasses-side processing capacity; it is recommended to add queuing and timeout/retry.
Mapping to Android
| Android | iOS |
|---|---|
sendCustomCmd(key, Caps.serialize()) | sendCustomCmd(cmd:payload:) |
ICustomCmdCbk.onCustomCmdResult | callback of sendCustomCmd |
Sample notes
Some historical demos do not split out a dedicated “Custom Command” page, and instead embed buttons and logs in the main ViewController. Follow the actual code in ios_cxr_l_sample to complete your own “Sample entry” mapping.