deleteKey method

Future<bool> deleteKey(
  1. LocationNotificationModel locationNotificationModel
)

Deletes originally created locationNotificationModel notification

Implementation

Future<bool> deleteKey(
    LocationNotificationModel locationNotificationModel) async {
  var atkeyMicrosecondId = locationNotificationModel.key!
      .split('requestlocation-')[1]
      .split('@')[0];

  var response =
      await AtLocationNotificationListener().atClientInstance!.getKeys(
            regex: 'requestlocation-$atkeyMicrosecondId',
          );

  var key = getAtKey(response[0]);

  locationNotificationModel.isAcknowledgment = true;

  var result =
      await AtLocationNotificationListener().atClientInstance!.delete(
            key,
            isDedicated: MixedConstants.isDedicated,
          );
  print('$key delete operation $result');

  if (result) {
    if (MixedConstants.isDedicated) {
      await SyncSecondary().callSyncSecondary(SyncOperation.syncSecondary);
    }
    KeyStreamService().removeData(key.key);
  }
  return result;
}