renewAgoraToken method

Future<void> renewAgoraToken(
  1. String agoraToken
)

~english Renews the Agora token.

If a user is logged in with an Agora token, when the token expires, you need to call this method to update the token.

Param agoraToken The new Agora token.

Throws A description of the exception. See EMError. ~end

~chinese 当用户在声网 token 登录状态时,且在 EMConnectionEventHandler.onTokenWillExpire 实现类中收到 token 即将过期事件的回调通知可以调用这个 API 来更新 token,避免因 token 失效产生的未知问题。

Param agoraToken 新声网 Token.

Throws 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError。 ~end

Implementation

Future<void> renewAgoraToken(String agoraToken) async {
  Map req = {"agora_token": agoraToken};

  Map result =
      await ClientChannel.invokeMethod(ChatMethodKeys.renewToken, req);
  try {
    EMError.hasErrorFromResult(result);
  } on EMError catch (e) {
    throw e;
  }
}