getActiveCall static method

Future<Call?> getActiveCall()

Gets the currently active call session.

Migration Note: Migrated from platform channels to native Dart implementation. Uses CallRepository for retrieving active call. Behavior and signature remain identical for backward compatibility.

Android Reference: CometChat.getActiveCall()

Implementation

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

    // Call native Dart call repository - returns raw response map
    final responseData = await sdk.calls.getActiveCallRaw();

    // Parse using Call.fromMap() to match Android SDK's Call.fromJson()
    if (responseData != null) {
      return Call.fromMap(responseData);
    }
    return null;
  } on SdkException catch (_) {
    // Log error but return null (matches original behavior)
    return null;
  } catch (e) {
    return null;
  }
}