inviteUserToGroup static method

Future<V2TimValueCallback<List<V2TimGroupMemberOperationResult>>> inviteUserToGroup({
  1. required String groupID,
  2. required List<String> userList,
})

Implementation

static Future<V2TimValueCallback<List<V2TimGroupMemberOperationResult>>> inviteUserToGroup({
  required String groupID,
  required List<String> userList,
}) async {
  String param = json.encode({
    "group_invite_member_param_group_id": groupID,
    "group_invite_member_param_identifier_array": userList,
  });
  String userData = Tools.generateUserData();
  Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
  Pointer<Uint8> json_group_invite_param = Tools.string2PointerInt8(param);
  int res = desktopSDK.D_TIMGroupInviteMember(json_group_invite_param, user_data);
  if (res != TIMResult.TIM_SUCC) {
    return V2TimValueCallback<List<V2TimGroupMemberOperationResult>>.fromJson({
      "code": res,
      "desc": "",
    });
  } else {
    Map<String, dynamic> data = await getAsyncData(apiKey: userData);
    List<Map<String, dynamic>> nativeData = List<Map<String, dynamic>>.from(json.decode(data["json_param"].isEmpty ? json.encode([]) : data["json_param"]));
    List<Map<String, dynamic>> memList = List.empty(growable: true);
    for (var element in nativeData) {
      memList.add({"memberID": element["group_invite_member_result_identifier"], "result": element["group_invite_member_result_result"]});
    }

    return V2TimValueCallback<List<V2TimGroupMemberOperationResult>>.fromJson({"code": data["code"], "desc": data["desc"], "data": memList});
  }
}