invite static method

Future<V2TimValueCallback<String>> invite({
  1. required String invitee,
  2. required String data,
  3. int timeout = 30,
  4. bool onlineUserOnly = false,
  5. OfflinePushInfo? offlinePushInfo,
})

Implementation

static Future<V2TimValueCallback<String>> invite({
  required String invitee,
  required String data,
  int timeout = 30,
  bool onlineUserOnly = false,
  OfflinePushInfo? offlinePushInfo,
}) async {
  // send custom message and handle timeout.
  V2TimValueCallback<String> user = await getLoginUser();
  String inviteID = Tools.generateUserData();
  String customData = _buildSignalData(
    type: V2SignalingActionType.SIGNALING_ACTION_TYPE_INVITE,
    customData: data,
    inviteID: inviteID,
    timeout: timeout,
    groupID: "",
    inviteeList: [invitee],
    inviter: user.data ?? "",
    onlineUserOnly: onlineUserOnly,
  );
  int code = await _sendCustomData(
    data: customData,
    toUserId: invitee,
    pusinfo: offlinePushInfo,
    onlineUserOnly: onlineUserOnly,
  );
  if (code == 0) {
    currentInvite = json.decode(customData);
    _timeout(timeout, inviteID);
  }
  return V2TimValueCallback(
    code: code,
    data: inviteID,
    desc: code == 0 ? "success" : "error",
  );
}