updateUserInfo method
~english Modifies the user attributes of the current user.
Param nickname
The nickname of the user.
Param avatarUrl
The avatar URL of the user.
Param mail
The email address of the user.
Param phone
The phone number of the user.
Param gender
The gender of the user. The value can only be 0
, 1
, or 2
. Other values are invalid.
0
: (Default) Unknown;1
: Male;2
: Female. Paramsign
The signature of the user.
Param birth
The birthday of the user.
Param ext
The custom extension information of the user. You can set it to an empty string or type custom information and encapsulate them as a JSON string.
Return The user info.
Throws A description of the exception. See ChatError. ~end
~chinese 修改当前用户的属性信息。
Param nickname
用户昵称。该昵称与推送设置中的昵称设置不同,我们建议这两种昵称的设置保持一致。设置推送昵称详见 ChatPushManager.updatePushNickname。
Param avatarUrl
用户头像。
Param mail
用户邮箱。
Param phone
用户手机号。
Param gender
用户性别。
0
: (默认) 未知;1
: 男;2
: 女.
Param sign
用户签名。
Param birth
用户的生日。
Param ext
用户的自定义属性字段。该字段可为空,或设置为自定义扩展信息,封装为 JSON 字符串。
Return 用户属性信息。
Throws 如果有方法调用的异常会在这里抛出,可以看到具体错误原因。请参见 ChatError。 ~end
Implementation
Future<ChatUserInfo> updateUserInfo({
String? nickname,
String? avatarUrl,
String? mail,
String? phone,
int? gender,
String? sign,
String? birth,
String? ext,
}) async {
Map req = {};
req.putIfNotNull("nickName", nickname);
req.putIfNotNull("avatarUrl", avatarUrl);
req.putIfNotNull("mail", mail);
req.putIfNotNull("phone", phone);
req.putIfNotNull("gender", gender);
req.putIfNotNull("sign", sign);
req.putIfNotNull("birth", birth);
req.putIfNotNull("ext", ext);
try {
Map result =
await _channel.invokeMethod(ChatMethodKeys.updateOwnUserInfo, req);
ChatError.hasErrorFromResult(result);
ChatUserInfo info =
ChatUserInfo.fromJson(result[ChatMethodKeys.updateOwnUserInfo]);
_effectiveUserInfoMap[info.userId] = info;
return info;
} on ChatError catch (e) {
throw e;
}
}