checkFriend static method
Future<V2TimValueCallback<List<V2TimFriendCheckResult>>>
checkFriend(
{ - required List<String> userIDList,
- required int checkType,
})
Implementation
static Future<V2TimValueCallback<List<V2TimFriendCheckResult>>> checkFriend({
required List<String> userIDList,
required int checkType,
}) async {
String param = json.encode({
"friendship_check_friendtype_param_check_type": checkType - 1, //这也是个神奇的地方,和native不一样
"friendship_check_friendtype_param_identifier_array": userIDList
});
String userData = Tools.generateUserData();
Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
Pointer<Uint8> json_check_friend_list_param = Tools.string2PointerInt8(param);
int res = desktopSDK.D_TIMFriendshipCheckFriendType(json_check_friend_list_param, user_data);
if (res != TIMResult.TIM_SUCC) {
return V2TimValueCallback<List<V2TimFriendCheckResult>>.fromJson({
"code": res,
"desc": "",
});
} else {
Map<String, dynamic> data = await getAsyncData(apiKey: userData);
List<Map<String, dynamic>> dataList = List<Map<String, dynamic>>.from(json.decode(data["json_param"].isEmpty ? json.encode([]) : data["json_param"]));
List<Map<String, dynamic>> list = List<Map<String, dynamic>>.empty(growable: true);
for (var element in dataList) {
Map<String, dynamic> json = Map.from(element);
V2TimFriendCheckResult result = V2TimFriendCheckResult.fromJson({
"userID": json["friendship_check_friendtype_result_identifier"],
"resultCode": json["friendship_check_friendtype_result_code"],
"resultInfo": json["friendship_check_friendtype_result_desc"],
"resultType": json["friendship_check_friendtype_result_relation"],
});
list.add(result.toJson());
}
return V2TimValueCallback<List<V2TimFriendCheckResult>>.fromJson({
"code": data["code"],
"desc": data["desc"],
"data": list,
});
}
}