deleteData method

dynamic deleteData(
  1. LocationNotificationModel locationNotificationModel
)

Deletes data associated with a LocationNotificationModel

Implementation

deleteData(LocationNotificationModel locationNotificationModel) async {
  if (isPastNotification(locationNotificationModel)) {
    notifyListeners();
    return;
  }

  var key = locationNotificationModel.key!;
  var keyKeyword = key.split('-')[0];
  var atkeyMicrosecondId = key.split('-')[1].split('@')[0];
  var response = await AtClientManager.getInstance().atClient.getKeys(
        regex: '$keyKeyword-$atkeyMicrosecondId',
      );
  if (response.isEmpty) {
    return;
  }

  var atkey = getAtKey(response[0]);
  await AtClientManager.getInstance().atClient.delete(atkey);
  removeData(key);
}