From 076e664ced7f24b49c5f30bf02f5e9c65ceabd68 Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Mon, 2 Dec 2024 17:15:19 +0100 Subject: [PATCH] change(react-native): android use promise --- .../java/com/openreplay/reactnative/ReactNativeModule.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tracker/tracker-reactnative/android/src/main/java/com/openreplay/reactnative/ReactNativeModule.kt b/tracker/tracker-reactnative/android/src/main/java/com/openreplay/reactnative/ReactNativeModule.kt index 3b2dc7817..758d83978 100644 --- a/tracker/tracker-reactnative/android/src/main/java/com/openreplay/reactnative/ReactNativeModule.kt +++ b/tracker/tracker-reactnative/android/src/main/java/com/openreplay/reactnative/ReactNativeModule.kt @@ -95,8 +95,13 @@ class ReactNativeModule(reactContext: ReactApplicationContext) : } @ReactMethod - fun getSessionId(): String { - return OpenReplay.getSessionId() + fun getSessionID(promise: Promise) { + try { + val sessionId = OpenReplay.getSessionID() ?: "" + promise.resolve(sessionId) // Resolve the promise with the session ID + } catch (e: Exception) { + promise.reject("GET_SESSION_ID_ERROR", "Failed to retrieve session ID", e) + } } @ReactMethod