getAllNotifications method
void
getAllNotifications()
adds all share and request location notifications to atNotificationsSink
Implementation
void getAllNotifications() async {
AtClientManager.getInstance().atClient.syncService.sync();
var allResponse = await atClientInstance!.getKeys(
regex: 'sharelocation-',
);
var allRequestResponse = await atClientInstance!.getKeys(
regex: 'requestlocation-',
);
allResponse = [...allResponse, ...allRequestResponse];
if (allResponse.isEmpty) {
SendLocationNotification().init(atClientInstance);
notifyListeners();
return;
}
await Future.forEach(allResponse, (String key) async {
var _atKey = getAtKey(key);
AtValue? value = await getAtValue(_atKey);
if (value != null) {
try {
if ((value.value != null) && (value.value != 'null')) {
var locationNotificationModel =
LocationNotificationModel.fromJson(jsonDecode(value.value));
allLocationNotifications.insert(
0,
KeyLocationModel(
locationNotificationModel:
locationNotificationModel)); // last item to come in would be at the top of the list
}
} catch (e) {
_logger.severe('convertJsonToLocationModel error :$e');
}
}
});
filterData();
await checkForPendingLocations();
notifyListeners();
SendLocationNotification().init(atClientInstance);
}