Development Flow & State-Machine
Development Flow & State-Machine
End-to-end development flow
CustomViewCustomAppcustomViewOpen_okopenApp_okAudioPhotoAudioPhotoCustomCmdDevEnvAndReposSdkImportAuthGetTokenSessionTypeConnectCustomViewConnectCustomAppSceneBuiltOnGlasses_CustomViewSceneBuiltOnGlasses_CustomAppCapability_CustomViewCapability_CustomAppAudioStreamPhotoCaptureCustomCommand
Description:
- DevEnv: phone OS version, Bluetooth permission, Rokid AI App, glasses firmware, and (if needed) glasses-side samples are ready.
- SdkImport: Gradle / CocoaPods and manifest configuration are completed.
- Auth: obtain a valid
token. - Session: choose
CUSTOMVIEWorCUSTOMAPP(Android enum), then completeconfigCXRSessionandconnect. - SceneBuiltOnGlasses (scene building): the glasses side has opened the Custom View (e.g.,
customViewOpensucceeds) or launched the target Custom App (e.g.,openAppsucceeds and the app is interactive). - Capability gating:
- Audio / Photo: in both
CustomViewandCustomAppscenarios, call only after the link and the scene are ready. - Custom Command: available only when the scenario type is Custom App (CustomApp), and requires the target app to be opened and interactive.
- Audio / Photo: in both
- The above gating rules are consistent across Android and iOS (see platform sections below).
Android: authentication result states (logic)
You can refer to MainViewModel.checkAuthorizationResult:
requestAuthorizationAuthSuccessAuthFailAuthCancelclearOrReauthIdlePendingAuthAuthedFailedCancelled
- Success:
AuthResult.AuthSuccesspersists thetoken,_isAuthorized = true. - Failure/cancel: clear token,
_isAuthorized = false.
Android: transport link and session (CXRLink)
Two key booleans are reported via ICXRLinkCbk (overridden in multiple places in the Sample):
onCXRLConnected(Boolean): CXR service-side connection.onGlassBtConnected(Boolean): glasses Bluetooth connection.
CustomAppTypeViewModel approximates “operational” as both being true (connectSuccess).
configCXRSessionconnect_tokenonCXRLConnected_trueonCXRLConnected_falseonGlassBtConnected_trueonGlassBtConnected_falseboth_truecapability_blockedscene_built_on_glassesaudio_photo_cmd_okLinkCreatedSessionConfiguredConnectRequestedTransportUpTransportDownBtUpBtDownLinkReadyNotReadySceneReadyReadyForCapability
See “Feature Development/Android/Connection and Session” for detailed explanation and code locations. Link ready (LinkReady) ≠ Scene ready (SceneReady): only the latter allows stable use of photo capture, audio, and custom commands.
Android: capability gating (aligned with the Sample)
CustomCmdentryType_customAppsharedCxrLink_nonnullappOpened_trueAudioAndPhotosharedCxrLink_nonnullscene_opened_on_glasses
- Audio / Photo:
sharedCxrLinkis created by the scene creation page andconnectis called; and the user must first complete scene building. - Custom Command: the scene type must be a Custom App, and the glasses-side app is opened.
Cross-platform consistency: unified gating rules (Android / iOS)
- Audio / Photo: available in both
CustomViewandCustomAppscenarios, but require link readiness + scene building first. - Custom Command: CustomApp only; not available in
CustomView. - Platform consistency: docs and implementations on Android and iOS should describe the above rules consistently.
iOS: authentication and link (concept)
- Observe authentication state via
client.auth.statePublisher/eventPublisher(see “Feature Development/iOS/Authentication”). - Observe runtime events via
audioEventPublisher,customViewRunningEventPublisher, etc.
authenticatesuccessfailurelink_readyscene_built_customView_or_customAppaudio_photo_cmd_allowedlogout_or_expireUnauthenticatedAuthenticatingAuthenticatedLinkReadySceneReadyReadyForFeatures
Note: ReadyForFeatures indicates that on iOS you should also complete the glasses-side Custom View running or Custom App launch before using capabilities.
The gating rules are the same as Android: audio/photo can be used in CustomView and CustomApp; custom commands are only for CustomApp. The exact event names follow RGCxrClient.