本文介绍如何设置用户的头像和昵称。
设置头像、昵称
如果您需要自定义昵称或头像,可以使用如下接口进行更新:
import com.tencent.qcloud.tuikit.TUICommonDefine
import com.tencent.qcloud.tuikit.tuicallkit.TUICallKit
TUICallKit.createInstance(context).setSelfInfo("jack", "https:/****/user_avatar.png",
object : TUICommonDefine.Callback {
override fun onSuccess() {
}
override fun onError(errorCode: Int, errorMessage: String?) {
}
})
import com.tencent.qcloud.tuikit.TUICommonDefine;
import com.tencent.qcloud.tuikit.tuicallkit.TUICallKit;
TUICallKit.createInstance(context).setSelfInfo("jack", "https:/****/user_avatar.png", new TUICommonDefine.Callback() {
@Override
public void onSuccess() {
}
@Override
public void onError(int errorCode, String errorMessage) {
}
});
import TUICallKit_Swift
import TUICallEngine
TUICallKit.createInstance().setSelfInfo(nickname: "", avatar: "") {
} fail: { code, message in
}
#import <TUICallKit_Swift/TUICallKit_Swift-Swift.h>
[[TUICallKit createInstance] setSelfInfoWithNickname:@"" avatar:@"" succ:^{
} fail:^(int code, NSString * _Nullable errMsg) {
}];
import 'package:tencent_calls_uikit/tencent_calls_uikit.dart';
void setSelfInfo() {
TUIResult result = TUICallKit.instance.setSelfInfo('userName', 'url:********');
}
import { TUICallKitServer } from '@tencentcloud/call-uikit-vue';
try {
await TUICallKitServer.setSelfInfo({ nickName: "jack", avatar: "http://xxx" });
} catch (error) {
console.error(`[TUICallKit] Failed to call the setSelfInfo API. Reason: ${error}`);
}
const options = {
nickName: 'jack',
avatar: 'https:/****/user_avatar.png'
};
TUICallKit.setSelfInfo(options, (res) => {
if (res.code === 0) {
console.log('setSelfInfo success');
} else {
console.log(`setSelfInfo failed, error message = ${res.msg}`);
}
});
注意
因为用户隐私限制,非好友之间的通话,被叫的昵称和头像更新可能会有延迟,一次通话成功后就会顺利更新。
本页内容是否解决了您的问题?