LandingView
Overview
The LandingView serves as the entry point for the MultiSet SDK demo application. It demonstrates SDK initialization, authentication handling, and navigation to the AR localization view.
Description
This SwiftUI view is responsible for:
Initializing the MultiSet SDK with credentials
Handling the authentication flow
Allowing users to select localization mode (Single-Frame or Multi-Frame)
Navigating to the AR localization session
Displaying configured object codes and navigating to the object tracking session
Authentication Flow
1. SDK Initialization
The SDK is initialized using credentials from SDKConfig:
// Build config from SDKConfig
var config = SDKConfig.buildConfig()
config.localizationMode = selectedMode // Override with UI selection
// Initialize SDK
MultiSet.shared.initialize(config: config, callback: sdkDelegate)2. Configuration Options
Configuration is built using MultiSetConfig:
baseURL
API host every endpoint is built from, defaults to production
clientId
Your client identifier
clientSecret
Your secret key
mapCode
Single map code for localization
mapSetCode
MapSet code for localizing against multiple maps
localizationMode
.singleFrame or .multiFrame
queryMode
.vps1 or .vps2, applies to single-frame queries only
poseConsistencyCheck
Discard results that contradict the device's AR trajectory
meshVisualization
Enable/disable 3D mesh overlay visualization
backgroundLocalization
Enable/disable background localization
objectCodes
Array of object codes to track
autoObjectTracking
Enable/disable auto object tracking on view appear
See MultiSetConfig for the full list.
3. Authentication Callbacks
The view uses MultiSetSDKDelegate (implementing MultiSetCallback) to receive authentication events:
APIs Used for Authentication
MultiSet
MultiSet.shared.initialize(config:callback:)
Initializes the SDK with configuration and callback
MultiSet.shared.setLocalizationMode(_:)
Updates the localization mode at runtime
MultiSet.shared.updateConfig(_:)
Applies an updated configuration to the running SDK before the next query (see Updating Configuration at Runtime)
MultiSet.shared.isInitialized
Check if SDK is initialized
MultiSet.shared.isAuthenticated
Check if authentication succeeded
MultiSetConfig
clientId
String
Client identifier for authentication
clientSecret
String
Secret key for authentication
mapCode
String
Sets the map code for single-map localization
mapSetCode
String
Sets the mapSet code for multi-map localization
localizationMode
LocalizationMode
Sets .singleFrame or .multiFrame mode
meshVisualization
Bool
Enables mesh visualization after localization
backgroundLocalization
Bool
Enables background localization
UI Components
Cards
The landing screen has two feature cards:
Localization Card
Displays the active map code (from
SDKConfig)Mode picker: Single Frame / Multi Frame
Start Localization button: navigates to
ARLocalizationView
Object Tracking Card
Displays the count of configured object codes
Scrollable list of object code badges
Start Object Tracking button: navigates to
ARObjectTrackingView
Both buttons are disabled until authentication succeeds.
Configuration (Settings) Screen
A gear icon in the navigation bar opens a full-screen Configuration screen (SettingsView) that edits the Map / MapSet localization and object-tracking behavior at runtime. It is backed by a ConfigStore that persists values across launches via UserDefaults, and on Save / Reset it calls MultiSet.shared.updateConfig(_:) so the changes apply to the running SDK before the next query, with no relaunch required. See Updating Configuration at Runtime.
State Properties
sdkDelegate
MultiSetSDKDelegate
ObservableObject that handles SDK callbacks
navigateToAR
Bool
Controls navigation to ARLocalizationView
navigateToObjectTracking
Bool
Controls navigation to ARObjectTrackingView
selectedMode
LocalizationMode
Currently selected localization mode
showToast
Bool
Controls toast message visibility
Callbacks (MultiSetCallback Protocol)
onSDKReady()
Called when the SDK has been initialized and is beginning authentication.
onAuthenticationSuccess()
Called when authentication with the MultiSet backend is successful.
onAuthenticationFailure(error: String)
Called when authentication fails.
error
String
Error message describing the failure reason
onLocalizationSuccess(result: LocalizationResult)
Called when localization succeeds. In LandingView, this is handled by the AR view.
result
LocalizationResult
Contains map ID, position, rotation, confidence, and optional geo-coordinates
onLocalizationFailure(error: String)
Called when localization fails. In LandingView, this is handled by the AR view.
error
String
Error message describing the failure reason
onLocalizationFalsePositive(info: FalsePositiveInfo)
Optional. Called when the server returned a pose that contradicts the device's own AR trajectory, so the SDK discarded it. Fires instead of onLocalizationSuccess, and only when poseConsistencyCheck is enabled. In LandingView, this is handled by ARLocalizationView.
info
FalsePositiveInfo
Details of the discarded response
See MultiSetCallback.
onTrackingStateChanged(state: TrackingState)
Called when AR tracking state changes. In LandingView, this is handled by the AR view.
state
TrackingState
Current tracking state (.tracking, .paused, .stopped)
onObjectTrackingSuccess(objectCode: String, confidence: Double)
Called when an object is successfully detected. In LandingView, this is handled by ARObjectTrackingView.
objectCode
String
Code of the detected object
confidence
Double
Detection confidence (0.0 to 1.0)
onObjectTrackingFailure(error: String)
Called when object tracking fails. In LandingView, this is handled by ARObjectTrackingView.
error
String
Error message describing the failure reason
LocalizationResult
mapCode
String
The code of the map where localization succeeded
mapCodes
[String]
All map codes returned, several for a MapSet
position
SIMD3<Float>
Computed XYZ position in AR world coordinates
rotation
simd_quatf
Computed XYZW quaternion rotation
confidence
Float?
Confidence score of the localization (0.0 to 1.0)
geoCoordinates
GeoCoordinates?
Optional geographic position
geoPose
GeoPose?
Optional full geographic pose, including orientation
timestamp
Date
When the result was produced
mode
LocalizationMode
The localization mode used
The raw server pose and the query camera pose behind the computed values are also exposed. See LocalizationResult for the full reference.
TrackingState
.tracking
AR tracking is working normally
.paused
AR tracking is temporarily paused
.stopped
AR tracking has stopped
LocalizationMode
.singleFrame
Single frame capture mode - quick but lower accuracy
.multiFrame
Multi-frame capture mode - slower but higher accuracy
Usage Example
Lifecycle
onAppear
Checks if credentials are configured
Auto-initializes SDK if credentials exist and not yet initialized
Navigation
Uses
NavigationStackwithnavigationDestinationfor programmatic navigationPasses
sdkDelegateandlocalizationModetoARLocalizationView
Related
Last updated
Was this helpful?

