From 0be7b1d035946a5106fc14c36f8255f94785632c Mon Sep 17 00:00:00 2001 From: Adwin Ronald Ross Date: Tue, 31 Dec 2024 16:53:01 +0530 Subject: [PATCH] feat(ios): expose API to get current session ID --- ios/MeasureSDK/Measure.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ios/MeasureSDK/Measure.swift b/ios/MeasureSDK/Measure.swift index b705d6e18..9148c933d 100644 --- a/ios/MeasureSDK/Measure.swift +++ b/ios/MeasureSDK/Measure.swift @@ -82,4 +82,15 @@ import Foundation } } } + + /// Returns the session ID for the current session, or nil if the SDK has not been initialized. + /// + /// A session represents a continuous period of activity in the app. A new session begins when the app is launched for the first time, or when there's been no activity for a 20-minute period. + /// A single session can continue across multiple app background and foreground events; brief interruptions will not cause a new session to be created. + /// - Returns: The session ID if the SDK is initialized, or nil otherwise. + func getSessionId() -> String? { + guard let sessionId = measureInternal?.sessionManager.sessionId else { return nil } + + return sessionId + } }