shareLocationAcknowledgment method
Sends a 'sharelocationacknowledged' key to originalLocationNotificationModel.atsignCreator with isAccepted as isAccepted
Implementation
Future<bool> shareLocationAcknowledgment(
LocationNotificationModel originalLocationNotificationModel,
bool isAccepted) async {
try {
var locationNotificationModel = LocationNotificationModel.fromJson(
jsonDecode(
LocationNotificationModel.convertLocationNotificationToJson(
originalLocationNotificationModel)));
var atkeyMicrosecondId = locationNotificationModel.key!
.split('sharelocation-')[1]
.split('@')[0];
var atKey = newAtKey(-1, 'sharelocationacknowledged-$atkeyMicrosecondId',
locationNotificationModel.atsignCreator);
locationNotificationModel.isAccepted = isAccepted;
locationNotificationModel.isExited = !isAccepted;
var result = await AtLocationNotificationListener().atClientInstance!.put(
atKey,
LocationNotificationModel.convertLocationNotificationToJson(
locationNotificationModel),
isDedicated: MixedConstants.isDedicated,
);
print('sendLocationNotificationAcknowledgment:$result');
if (result) {
if (MixedConstants.isDedicated) {
await SyncSecondary().callSyncSecondary(SyncOperation.syncSecondary);
}
KeyStreamService().updatePendingStatus(locationNotificationModel);
}
return result;
} catch (e) {
print('sending share awk failed $e');
return false;
}
}