getUserAuthToken static method

Future<String?> getUserAuthToken()

Get the current user's auth token.

Migration Note: Migrated from platform channels to native Dart implementation. Uses AuthRepository to get the stored auth token. Behavior and signature remain identical for backward compatibility.

Android Reference: CometChat.getUserAuthToken()

Returns the auth token or null if user is not logged in.

Implementation

static Future<String?> getUserAuthToken() async {
  try {
    // Get SDK instance
    final sdk = SdkRegistry.getInstance();

    // Get auth token from auth repository
    return await sdk.auth.getUserAuthToken();
  } catch (e) {
    return null;
  }
}