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:

  1. Initializing the MultiSet SDK with credentials

  2. Handling the authentication flow

  3. Allowing users to select localization mode (Single-Frame or Multi-Frame)

  4. Navigating to the AR localization 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:

Property
Description

clientId

Your client identifier

clientSecret

Your secret key

mapCode

Single map code for localization

mapSetCode

Map set code for localizing against multiple maps

localizationMode

.singleFrame or .multiFrame

meshVisualization

Enable/disable 3D mesh overlay visualization

backgroundLocalization

Enable/disable background localization

3. Authentication Callbacks

The view uses MultiSetSDKDelegate (implementing MultiSetCallback) to receive authentication events:


APIs Used for Authentication

MultiSet

Method
Description

MultiSet.shared.initialize(config:callback:)

Initializes the SDK with configuration and callback

MultiSet.shared.setLocalizationMode(_:)

Updates the localization mode at runtime

MultiSet.shared.isInitialized

Check if SDK is initialized

MultiSet.shared.isAuthenticated

Check if authentication succeeded

MultiSetConfig

Property
Type
Description

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 map set 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

State Properties

Property
Type
Description

sdkDelegate

MultiSetSDKDelegate

ObservableObject that handles SDK callbacks

navigateToAR

Bool

Controls navigation to AR view

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.

Parameter
Type
Description

error

String

Error message describing the failure reason

onLocalizationSuccess(result: LocalizationResult)

Called when localization succeeds. In LandingView, this is handled by the AR view.

Parameter
Type
Description

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.

Parameter
Type
Description

error

String

Error message describing the failure reason

onTrackingStateChanged(state: TrackingState)

Called when AR tracking state changes. In LandingView, this is handled by the AR view.

Parameter
Type
Description

state

TrackingState

Current tracking state (.tracking, .paused, .stopped)


LocalizationResult

Property
Type
Description

mapId

String

The ID of the map where localization succeeded

mapIds

[String]

All map IDs (for map sets)

position

SIMD3<Float>

XYZ position coordinates

rotation

simd_quatf

XYZW quaternion rotation

confidence

Float?

Confidence score of the localization (0.0 - 1.0)

geoCoordinates

GeoCoordinates?

Optional geographic coordinates

mode

LocalizationMode

The localization mode used


TrackingState

Value
Description

.tracking

AR tracking is working normally

.paused

AR tracking is temporarily paused

.stopped

AR tracking has stopped


LocalizationMode

Value
Description

.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

  • Uses NavigationStack with navigationDestination for programmatic navigation

  • Passes sdkDelegate and localizationMode to ARLocalizationView


Last updated