loginWithAgoraToken method

Future<void> loginWithAgoraToken(
  1. String userId,
  2. String agoraToken
)

Logs in to the chat server by user ID and Agora token. This method supports automatic login.

Another method to login to chat server is to login with user ID and token, See login.

Param userId The user Id.

Param agoraToken The Agora token.

Throws A description of the exception. See ChatError.

Implementation

Future<void> loginWithAgoraToken(String userId, String agoraToken) async {
  Map req = {
    "username": userId,
    "agora_token": agoraToken,
  };

  Map result = await ClientChannel.invokeMethod(
      ChatMethodKeys.loginWithAgoraToken, req);
  try {
    ChatError.hasErrorFromResult(result);
    _currentUserId = userId;
  } on ChatError catch (e) {
    throw e;
  }
}