loadPushNotificationsFromMobile method

Future<List<PamPushMessage>?> loadPushNotificationsFromMobile(
  1. String mobileNumber
)

Implementation

Future<List<PamPushMessage>?> loadPushNotificationsFromMobile(
    String mobileNumber) 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&sms=$mobileNumber"
  ]);
  try {
    var uri = Uri.parse(
        "$baseURL/api/app-notifications?_database=$db&_contact_id=$contact&sms=$mobileNumber");
    response = await HttpClient.get(uri);

    Pam.log([
      "LOAD PUSH NOTIFICATION",
      uri,
      "mobile number = $mobileNumber",
      "πŸš₯πŸš₯πŸš₯πŸš₯πŸš₯ 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;
}