NsdkSession
Declaration
final class NsdkSessionSummary
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
Summary
Overload 1
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") { <br /> // Session created successfully <br />} else { <br /> // Failed to load configuration <br />} <br />
Overload 2
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
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
| Name | Type | Summary |
|---|---|---|
| var currentFrame | NsdkFrameData | - |
| var delegate | ( NsdkSessionDelegate)? | A delegate for receiving ARSession updates. |
| var isAuthorized | Bool | 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 |
| let nativeHandle | NsdkHandle | 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
| Name | Type | Summary |
|---|---|---|
| createDepthSession | NsdkDepthSession | - |
| createDeviceMappingSession | NsdkDeviceMappingSession | Creates a new Mapping session. - Returns: A new Device Mapping session attached to this NSDK session |
| createMapStorage | NsdkMapStorage | - |
| createMeshDownloader | NsdkMeshDownloader | Creates a new Mesh Downloader instance. - Returns: A new NsdkMeshDownloader attached to this NSDK session. |
| createMeshingSession | NsdkMeshingSession | Creates a new Meshing session. - Returns: A new Meshing session attached to this NSDK session |
| createObjectDetectionSession | NsdkObjectDetectionSession | - |
| createRecordingExporter | NsdkRecordingExporter | 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 |
| createScanningSession | NsdkScanningSession | Creates a new Scanning session. - Returns: A new Scanning session attached to this NSDK session |
| createSemanticsSession | NsdkSemanticsSession | 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 |
| createSitesSession | NsdkSitesSession | - |
| createVps2Session | NsdkVps2Session | Creates a new VPS2 (Unified Localization System) session. - Returns: A new VPS2 session attached to this ARDK session |
| createVpsCoverageSession | NsdkVpsCoverageSession | Creates a new VPS Coverage session. - Returns: A new NsdkVpsCoverageSession instance attached to this NSDK session. |
| createVpsSession | NsdkVpsSession | Creates a new VPS (Visual Positioning System) session. - Returns: A new VPS session attached to this NSDK session |
| createWpsSession | NsdkWpsSession | Creates a new World Positioning System (WPS) session. - Returns: A new WPS session attached to this NSDK session |
| getAccessAuthInfo | AuthInfo? | 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 |
| getRefreshAuthInfo | AuthInfo? | 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 |
| requestedDataInputs | NsdkInputDataFlags | 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 |
| sendFrame | void | 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 |
| setAccessToken | void | Sets the access token on native (routed through AuthManagerApi via C-ABI). Empty or whitespace-only tokens are ignored by native. |
| setAgeLevel | void | 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 |
| setCallbackLogLevel | void | Sets the log level for callback logging. - Parameter logLevel: The desired log level for callback logging |
| setFileLogLevel | void | Sets the log level for file logging. - Parameter logLevel: The desired log level for file logging |
| setRefreshToken | void | Sets the refresh token on native (routed through AuthManagerApi via C-ABI). Empty or whitespace-only tokens are ignored by native. |
| setStdoutLogLevel | void | Sets the log level for standard output logging. - Parameter logLevel: The desired log level for standard output |
| static version | String | Retrieves the NSDK version string. |
Nested Types
Structs
| Name | Type | Summary |
|---|---|---|
| CloudEnvConfig | CloudEnvConfig | - |
| Configuration | Configuration | Configuration settings for initializing an NSDK session. This struct encapsulates various configuration options including device info, cloud environment settings, user credentials, and logging preferences. |
| DeviceInfo | DeviceInfo | - |
| UserConfig | UserConfig | - |
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
nilif configuration is invalid## Example
swift <br />let config = Configuration() <br />// Configure settings... <br />if let session = NsdkSession(withConfig: config) { <br /> // Session created successfully <br />} <br />