getCurrentUserId method

Future<String?> getCurrentUserId()

获取当前登录的用户 ID。

Return 当前登录的用户 ID。

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;
  }
}