CLASS
ArdkSession
public final class ArdkSession
The main entry point for the ARDK (Augmented Reality Development Kit) framework.
ArdkSession provides the core functionality for AR applications, managing the lifecycle
of ARDK features and serving as a factory for specialized sessions like VPS, WPS, scanning, and mapping.
This class handles frame data processing, configuration management, and resource cleanup.
Overview
Use ArdkSession to:
- Initialize the ARDK with your API key and configuration
- Send camera frame data for processing
- Create specialized feature sessions (VPS, WPS, Scanning, Mapping)
- Query required input data formats
- Manage the lifecycle of ARDK resources
Example Usage
// Initialize with API key
let session = ArdkSession(apiKey: "your-api-key")
// Create a VPS session for localization
let vpsSession = session.createVpsSession()
// Send frame data during AR session
let status = session.sendFrame(frameData)
Properties
nativeHandle
public let nativeHandle: ArdkHandle
The native handle to the underlying ARDK C API instance.
This handle is used internally to communicate with the native ARDK library and should not be modified directly by application code.
Methods
init(apiKey:useLidar:pathConfig:logCallback:)
public convenience init(apiKey: String, useLidar: Bool = true, pathConfig: ArdkPathConfig? = nil, logCallback: ArdkLogCallback? = nil)
Creates a new ARDK session with the specified API key and configuration.
This is the recommended way to initialize ARDK for most use cases. The session will automatically configure itself with default settings appropriate for AR applications.
- Parameters:
- apiKey: Your ARDK API key obtained from the developer portal
- useLidar: Whether to use LiDAR depth data when available (default: true)
- pathConfig: Optional path configuration for custom file locations
- logCallback: Optional callback to receive ARDK log messages
Example
let session = ArdkSession(apiKey: "your-api-key")
let sessionWithoutLidar = ArdkSession(apiKey: "your-api-key", useLidar: false)
Parameters
| Name | Description |
|---|---|
| apiKey | Your ARDK API key obtained from the developer portal |
| useLidar | Whether to use LiDAR depth data when available (default: true) |
| pathConfig | Optional path configuration for custom file locations |
| logCallback | Optional callback to receive ARDK log messages |
init(withJson:logCallback:)
public convenience init?(withJson configFilePath: String, logCallback: ArdkLogCallback? = nil)
Creates a new ARDK session from a JSON configuration file.
Use this initializer for fine-grained control over ARDK configuration or when loading settings from a configuration file.
- Parameters:
- configFilePath: Path to the JSON configuration file
- logCallback: Optional callback to receive ARDK log messages
- Returns: A new ARDK session, or
nilif configuration loading fails
Example
if let session = ArdkSession(withJson: "/path/to/config.json") {
// Session created successfully
} else {
// Failed to load configuration
}
Parameters
| Name | Description |
|---|---|
| configFilePath | Path to the JSON configuration file |
| logCallback | Optional callback to receive ARDK log messages |
init(withConfig:)
public convenience init?(withConfig config: Configuration)
Creates a new ARDK session with a Configuration object.
Use this initializer for fine-grained control over ARDK configuration
- Parameter config: The configuration object with defined settings
- Returns: A new ARDK session, or
nilif configuration is invalid
Example
let config = Configuration()
// Configure settings...
if let session = ArdkSession(withConfig: config) {
// Session created successfully
}
Parameters
| Name | Description |
|---|---|
| config | The configuration object with defined settings |
init(accessToken:refreshToken:useLidar:pathConfig:logCallback:)
public convenience init(accessToken: String, refreshToken: String, useLidar: Bool = true, pathConfig: ArdkPathConfig? = nil, logCallback: ArdkLogCallback? = nil)
Convenience initializer that accepts access and refresh tokens instead of an API key. Tokens are sanitized and passed to native AuthManagerApi immediately via creation call.
deinit
deinit
sendFrame(_:)
public func sendFrame(_ frameData: ArdkFrameData)
Sends a frame of data to ARDK for processing.
Call this method for each frame captured from an AR session. This will push the captured frame data into ARDK's native components for processing by active features.
- Parameter frameData: The frame data captured from the AR session
Parameters
| Name | Description |
|---|---|
| frameData | The frame data captured from the AR session |
requestedDataInputs()
public func requestedDataInputs() -> ArdkInputDataFlags
Get the current set of input data types that are required by ARDK's native components.
Use this method to determine what data should be included in frames sent to sendFrame(_:).
The required data formats may change based on currently active features and their states.
- Returns: Flags indicating which data types are currently required
Example
let requiredInputs = session.requestedDataInputs()
if requiredInputs.contains(.camera) {
// Include camera data in frame
}
if requiredInputs.contains(.depth) {
// Include depth data in frame
}
setStdoutLogLevel(logLevel:)
public func setStdoutLogLevel(logLevel: ArdkLogLevel)
Sets the log level for standard output logging.
- Parameter logLevel: The desired log level for standard output
Parameters
| Name | Description |
|---|---|
| logLevel | The desired log level for standard output |
setFileLogLevel(logLevel:)
public func setFileLogLevel(logLevel: ArdkLogLevel)
Sets the log level for file logging.
- Parameter logLevel: The desired log level for file logging
Parameters
| Name | Description |
|---|---|
| logLevel | The desired log level for file logging |
setCallbackLogLevel(logLevel:)
public func setCallbackLogLevel(logLevel: ArdkLogLevel)
Sets the log level for callback logging.
- Parameter logLevel: The desired log level for callback logging
Parameters
| Name | Description |
|---|---|
| logLevel | The desired log level for callback logging |
version()
public static func version() -> String
Retrieves the ARDK version string.
setAccessToken(_:)
public func setAccessToken(_ token: String)
Sets the access token on native (routed through AuthManagerApi via C-ABI). Empty or whitespace-only tokens are ignored by native.
setRefreshToken(_:)
public func setRefreshToken(_ token: String)
Sets the refresh token on native (routed through AuthManagerApi via C-ABI). Empty or whitespace-only tokens are ignored by native.