deleteKey method

Future<bool> deleteKey(
  1. LocationNotificationModel locationNotificationModel
)

Deletes originally created locationNotificationModel notification

Implementation

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

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

    var key = getAtKey(response[0]);

    locationNotificationModel.isAcknowledgment = true;

    var result = await AtLocationNotificationListener()
        .atClientInstance!
        .delete(key, isDedicated: MixedConstants.isDedicated);
    if (result) {
      if (MixedConstants.isDedicated) {
        await SyncSecondary().callSyncSecondary(SyncOperation.syncSecondary);
      }
      KeyStreamService().removeData(key.key);
    }
    return result;
  } catch (e) {
    print('error in deleting key $e');
    return false;
  }
}