Skip to main content
API Reference SwiftyNsdk

NsdkSession

The main entry point for the NSDK (Native SDK) framework....

Declaration

final class NsdkSession

Summary

The main entry point for the NSDK (Native SDK) framework. NsdkSession provides the core functionality for AR applications, managing the lifecycle of NSDK 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 NsdkSession to:

  • Initialize the NSDK 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 NSDK resources

Example Usage

// Initialize with API key
let session = NsdkSession(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)

Constructors

Constructor

convenience init?(withConfig config: Configuration)

Summary

Creates a new NSDK session with a Configuration object.
Use this initializer for fine-grained control over NSDK configuration
- Parameter config: The configuration object with defined settings
- Returns: A new NSDK session, or nil if configuration is invalid
## Example
swift <br />let config = Configuration() <br />// Configure settings... <br />if let session = NsdkSession(withConfig: config) &#123; <br /> // Session created successfully <br />&#125; <br />


Overload 1

convenience init?(withJson configFilePath: String, logCallback: NsdkLogCallback? = nil)

Summary

Creates a new NSDK session from a JSON configuration file.
Use this initializer for fine-grained control over NSDK configuration
or when loading settings from a configuration file.
- Parameters:
- configFilePath: Path to the JSON configuration file
- logCallback: Optional callback to receive NSDK log messages
- Returns: A new NSDK session, or nil if configuration loading fails
## Example
swift <br />if let session = NsdkSession(withJson: "/path/to/config.json") &#123; <br /> // Session created successfully <br />&#125; else &#123; <br /> // Failed to load configuration <br />&#125; <br />


Overload 2

convenience init(apiKey: String, useLidar: Bool = true, pathConfig: NsdkPathConfig? = nil, logCallback: NsdkLogCallback? = nil)

Summary

Creates a new NSDK session with the specified API key and configuration.
This is the recommended way to initialize NSDK for most use cases. The session will
automatically configure itself with default settings appropriate for AR applications.
- Parameters:
- apiKey: Your NSDK 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 NSDK log messages
## Example
swift <br />let session = NsdkSession(apiKey: "your-api-key") <br />let sessionWithoutLidar = NsdkSession(apiKey: "your-api-key", useLidar: false) <br />


Overload 3

convenience init(accessToken: String, refreshToken: String, useLidar: Bool = true, pathConfig: NsdkPathConfig? = nil, logCallback: NsdkLogCallback? = nil)

Summary

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.


Properties

NameTypeSummary
var currentFrameNsdkFrameData
-
var delegate ( NsdkSessionDelegate)?
A delegate for receiving ARSession updates.
var isAuthorizedBool
Returns true if a valid, non-expired access token is available.
Use this to check if features requiring authentication can be used.
If a feature returns an auth error, poll this property until it returns true
before retrying.
## Example
// After receiving an auth error from a feature:
while !session.isAuthorized {
try await Task.sleep(nanoseconds: 1_000_000_000) // 1 second
}
// Retry the feature call
let nativeHandleNsdkHandle
The native handle to the underlying NSDK C API instance.
This handle is used internally to communicate with the native NSDK library
and should not be modified directly by application code.

Methods

NameTypeSummary
createDepthSessionNsdkDepthSession
-
createDeviceMappingSessionNsdkDeviceMappingSession
Creates a new Mapping session.
- Returns: A new Device Mapping session attached to this NSDK session
createMapStorageNsdkMapStorage
-
createMeshDownloaderNsdkMeshDownloader
Creates a new Mesh Downloader instance.
- Returns: A new NsdkMeshDownloader attached to this NSDK session.
createMeshingSessionNsdkMeshingSession
Creates a new Meshing session.
- Returns: A new Meshing session attached to this NSDK session
createObjectDetectionSessionNsdkObjectDetectionSession
-
createRecordingExporterNsdkRecordingExporter
Creates a new Recording Exporter session.
Recording Export enables the conversion and export of saved scan recordings
to various formats for external processing or sharing. This session manages
the export workflow from scan selection through format conversion and output.
- Returns: A new Recording Exporter session attached to this NSDK session
createScanningSessionNsdkScanningSession
Creates a new Scanning session.
- Returns: A new Scanning session attached to this NSDK session
createSemanticsSessionNsdkSemanticsSession
Creates a new Semantics session.
Semantics enables pixel-level understanding of the environment by classifying
objects and surfaces in camera images. This session manages semantic segmentation
processing and provides access to semantic understanding results.
- Returns: A new Semantics session attached to this NSDK session
## Example
let session = NsdkSession(apiKey: "your-api-key")
let semanticsSession = session.createSemanticsSession()
createSitesSessionNsdkSitesSession
-
createVps2SessionNsdkVps2Session
Creates a new VPS2 (Unified Localization System) session.
- Returns: A new VPS2 session attached to this ARDK session
createVpsCoverageSessionNsdkVpsCoverageSession
Creates a new VPS Coverage session.
- Returns: A new NsdkVpsCoverageSession instance attached to this NSDK session.
createVpsSessionNsdkVpsSession
Creates a new VPS (Visual Positioning System) session.
- Returns: A new VPS session attached to this NSDK session
createWpsSessionNsdkWpsSession
Creates a new World Positioning System (WPS) session.
- Returns: A new WPS session attached to this NSDK session
getAccessAuthInfoAuthInfo?
Gets access token authentication information.
Returns authentication information containing information about the current access token.
- Returns: AuthInfo containing access token claims, or nil if the operation fails
getRefreshAuthInfoAuthInfo?
Gets refresh token authentication information.
Returns authentication information containing information about the current refresh token.
- Returns: AuthInfo containing refresh token claims, or nil if the operation fails
requestedDataInputsNsdkInputDataFlags
Get the current set of input data types that are required by NSDK'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
}
sendFramevoid
Sends a frame of data to NSDK for processing.
Call this method for each frame captured from an AR session. This will push
the captured frame data into NSDK's native components for processing by active features.
- Parameter frameData: The frame data captured from the AR session
setAccessTokenvoid
Sets the access token on native (routed through AuthManagerApi via C-ABI).
Empty or whitespace-only tokens are ignored by native.
setAgeLevelvoid
Sets the age level for the NSDK session.
This method sets the age classification for the user
- Parameter ageLevel: The age level to set (unknown, minor, teen, or adult)
## Example
session.setAgeLevel(.adult)
setCallbackLogLevelvoid
Sets the log level for callback logging.
- Parameter logLevel: The desired log level for callback logging
setFileLogLevelvoid
Sets the log level for file logging.
- Parameter logLevel: The desired log level for file logging
setRefreshTokenvoid
Sets the refresh token on native (routed through AuthManagerApi via C-ABI).
Empty or whitespace-only tokens are ignored by native.
setStdoutLogLevelvoid
Sets the log level for standard output logging.
- Parameter logLevel: The desired log level for standard output
static versionString
Retrieves the NSDK version string.

Nested Types

Structs

NameTypeSummary
CloudEnvConfigCloudEnvConfig
-
ConfigurationConfiguration
Configuration settings for initializing an NSDK session.
This struct encapsulates various configuration options
including device info, cloud environment settings, user credentials,
and logging preferences.
DeviceInfoDeviceInfo
-
UserConfigUserConfig
-