用户可以设置和获取个人的昵称、头像、签名等资料信息,也可以获取到陌生人的资料信息。
目前提供的关系链事件如下:
监听器 | 解释 |
---|---|
SetOnAddFriendCallback | 设置添加好友的回调。 |
SetOnDeleteFriendCallback | 设置删除好友的回调。 |
SetUpdateFriendProfileCallback | 设置更新好友资料的回调。 |
SetFriendAddRequestCallback | 设置好友添加请求的回调。 |
SetFriendApplicationListDeletedCallback | 设置好友申请被删除的回调。 |
SetFriendApplicationListReadCallback | 设置好友申请已读的回调。 |
SetFriendBlackListAddedCallback | 设置黑名单新增的回调。 |
SetFriendBlackListDeletedCallback | 设置黑名单删除的回调。 |
当不想再接收关系链事件时,可调用相同回调函数传入 null
移除关系链事件监听器。
注意:只有预先设置好关系链事件监听器,才能正常接收到下文中的各种事件通知。
您可以调用 ProfileGetUserProfileList
(Details) 接口查询个人资料,其中参数 friendship_getprofilelist_param_identifier_array
需填入自己的 UserID。
您可以调用 ProfileModifySelfUserProfile
(Details) 接口修改个人资料。
示例代码如下:
// 获取个人资料
FriendShipGetProfileListParam param = new FriendShipGetProfileListParam
{
friendship_getprofilelist_param_identifier_array = new List<string>
{
"self_user_id"
}
};
TIMResult res = TencentIMSDK.ProfileGetUserProfileList(param, (int code, string desc, List<UserProfile> profile, string user_data)=>{
// 处理异步逻辑
});
// 设置个人资料
UserProfileItem param = new UserProfileItem{
user_profile_item_nick_name = "new_nick_name"
};
TIMResult res = TencentIMSDK.ProfileGetUserProfileList(param, (int code, string desc, string user_data)=>{
// 处理异步逻辑
});
您可以调用 ProfileGetUserProfileList
(Details) 接口查询非好友资料,其中参数 friendship_getprofilelist_param_identifier_array
填入非好友的 UserID 即可。
说明:不能修改非好友的资料。
您可以调用 FriendshipGetFriendsInfo
(Details) 接口查询指定的好友资料,从回调信息中通过 FriendInfoGetResult
的 friendship_friend_info_get_result_relation_type
字段可以得到该用户与自己的关系:
relation | 与自己的关系 |
---|---|
TIMFriendshipRelationType.kTIMFriendshipRelationType_None |
表示不是好友。 |
TIMFriendshipRelationType.kTIMFriendshipRelationType_BothFriend |
表示互为好友。 |
TIMFriendshipRelationType.kTIMFriendshipRelationType_InMyFriendList |
表示对方在我的好友列表中。 |
TIMFriendshipRelationType.kTIMFriendshipRelationType_InOtherFriendList |
表示我在对方的好友列表中。 |
// 获取好友信息
TIMResult res = TencentIMSDK.FriendshipGetFriendsInfo(friend_userids, (int code, string desc, List<FriendInfoGetResult> result, string user_data)=>{
// 处理异步逻辑
});
您可以调用 FriendshipModifyFriendProfile
(Details) 接口修改好友备注等资料。
// 设置好友信息
FriendshipModifyFriendProfileParam param = new FriendshipModifyFriendProfileParam
{
friendship_modify_friend_profile_param_identifier = "friend_userid",
friendship_modify_friend_profile_param_item = new FriendProfileItem
{
friend_profile_item_remark = "nickname" // 好友备注
}
};
TIMResult res = TencentIMSDK.FriendshipModifyFriendProfile(param, (int code, string desc, string user_data)=>{
// 处理异步逻辑
});
增强版 SDK 中用户资料的更新分好友和陌生人两种情况:
本页内容是否解决了您的问题?