getCurrentUserId method

Future<String?> getCurrentUserId()

~english Gets the current login user ID.

Return The current login user ID. ~end

~chinese 获取当前登录的用户 ID。

Return 当前登录的用户 ID。 ~end

Implementation

Future<String?> getCurrentUserId() async {
  Map result =
      await ClientChannel.invokeMethod(ChatMethodKeys.getCurrentUser);
  try {
    EMError.hasErrorFromResult(result);
    _currentUserId = result[ChatMethodKeys.getCurrentUser];
    if (_currentUserId != null) {
      if (_currentUserId!.length == 0) {
        _currentUserId = null;
      }
    }
    return _currentUserId;
  } on EMError catch (e) {
    throw e;
  }
}