changeAppKey method

Future<bool> changeAppKey({
  1. required String newAppKey,
})

~english Updates the App Key, which is the unique identifier to access Agora Chat.

You can retrieve the new App Key from Agora Console.

As this key controls all access to Agora Chat for your app, you can only update the key when the current user is logged out.

Param newAppKey The App Key. Ensure that you set this parameter.

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

~chinese 修改 App Key。

@note 只有在未登录状态才能修改 App Key。

Param newAppKey App Key,请确保设置该参数。

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

Implementation

Future<bool> changeAppKey({required String newAppKey}) async {
  EMLog.v('changeAppKey: $newAppKey');
  Map req = {'appKey': newAppKey};
  Map result =
      await ClientChannel.invokeMethod(ChatMethodKeys.changeAppKey, req);
  try {
    EMError.hasErrorFromResult(result);
    return result.boolValue(ChatMethodKeys.changeAppKey);
  } on EMError catch (e) {
    throw e;
  }
}