getSessionId method

Future<String> getSessionId()

Get the session id This is useful to track the user's session. The session id is a unique identifier for the user's session. The session id is received in the onSessionIdReceived callback. If the session id is not received, it will try to get the session id again. If the session id is not found, it will return 'Session ID not found'. If the session id is found, it will return the session id. If the session id is found and the onSessionIdReceived callback is not null, it will invoke the onSessionIdReceived callback.

Implementation

Future<String> getSessionId() async {
  String? sessionId = await webViewController?.evaluateJavascript(
      source: 'window.\$crisp.get("session:identifier")');
  if (sessionId != null && onSessionIdReceived != null) {
    onSessionIdReceived!(sessionId);
    return sessionId;
  }
  if (sessionId == null) getSessionId();
  return sessionId ?? 'Session ID not found';
}