loadPushNotificationsFromEmail method

Future<List<PamPushMessage>?> loadPushNotificationsFromEmail(
  1. String email
)

Implementation

Future<List<PamPushMessage>?> loadPushNotificationsFromEmail(
    String email) async {
  Response? response;
  var db = await Pam.shared.getDatabaseAlias();
  var contact = await Pam.shared.getContactID();

  Pam.log([
    "LOAD PUSH NOTIFICATION",
    "_database=$db&_contact_id=$contact&email=$email"
  ]);
  try {
    var uri = Uri.parse(
        "$baseURL/api/app-notifications?_database=$db&_contact_id=$contact&email=$email");
    response = await HttpClient.get(uri);
    Pam.log([
      "LOAD PUSH NOTIFICATION",
      uri,
      "email = $email",
      "πŸš₯πŸš₯πŸš₯πŸš₯πŸš₯ RESULT πŸš₯πŸš₯πŸš₯πŸš₯πŸš₯",
      "Status Code: ${response.statusCode}",
      "----- Response Body -----",
      response.body
    ]);
  } catch (e, stackTrace) {
    Pam.log(["ERROR", stackTrace, e]);
  }

  if (response != null) {
    return PamPushMessage.parse(response.body);
  }

  return null;
}