confirmDelivered static method

Future<bool> confirmDelivered(
  1. String token,
  2. String messageId,
  3. String transport,
  4. String? traceId,
)

Implementation

static Future<bool> confirmDelivered(
    String token, String messageId, String transport, String? traceId) async {
  var result = true;
  var basicAuth = "Basic ${base64.encode(utf8.encode('$token:$messageId'))}";
  try {
    await http
        .post(
            Uri.parse(
                'https://pub.pushed.ru/v2/confirm?transportKind=$transport'),
            headers: {
              "Content-Type": "application/json",
              if (traceId != null) "mf-trace-id": traceId,
              "Authorization": basicAuth
            },
            body: "")
        .timeout(const Duration(seconds: 10),
            onTimeout: (() => throw Exception("TimeOut")));
  } catch (e) {
    result = false;
  }
  return (result);
}