100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Fixed issue when refreshing geofences Improved implementation for push notifications
Michael Rademakere99d5e4f4b01
diff --git a/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart b/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dartindex fe1f248e3..65685bf40 100644--- a/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart+++ b/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart@@ -46,7 +46,7 @@ class GeofenceProvider {if (event == GeofenceEvent.enter) {ids.forEach((id) {GeofenceDefinition geofenceDefinition =- instance.geofences.firstWhere((element) => element.id == id);+ instance.geofences.firstWhere((element) => element.id == id, orElse: () => null);if (geofenceDefinition != null) {instance._queueSendLocation(geofenceDefinition, {"type": "Point",@@ -58,7 +58,7 @@ class GeofenceProvider {if (event == GeofenceEvent.exit) {ids.forEach((id) {GeofenceDefinition geofenceDefinition =- instance.geofences.firstWhere((element) => element.id == id);+ instance.geofences.firstWhere((element) => element.id == id, orElse: () => null);if (geofenceDefinition != null) {instance._queueSendLocation(geofenceDefinition, null);}@@ -196,14 +196,14 @@ class GeofenceProvider {GeofenceDefinition.fromJson).then((geofenceDefinitions) async {print("Fetched geofences=${geofenceDefinitions.length}");- List<GeofenceDefinition> remainingGeofences =+ List<GeofenceDefinition> remainingGeofences = List.from(geofenceDefinitions);new List<GeofenceDefinition>();geofences.forEach((oldGeofence) async {if (!geofenceDefinitions.any((definition) => definition.id == oldGeofence.id)) {await removeGeofence(oldGeofence.id);} else {- remainingGeofences.add(oldGeofence);+ remainingGeofences.removeWhere((element) => element.id == oldGeofence.id);}});diff --git a/console/generic_app/lib/services/PushNotificationService.dart b/console/generic_app/lib/services/PushNotificationService.dartindex 2c4868bd8..44c2362bd 100644--- a/console/generic_app/lib/services/PushNotificationService.dart+++ b/console/generic_app/lib/services/PushNotificationService.dart@@ -89,6 +89,8 @@ class PushNotificationService {String body = messageData["or-body"];List<AlertButton> buttons;+ AlertButton confirmButton;+ AlertButton declineButton;AlertAction action;// Check for action (to be executed when notification is clicked)@@ -108,31 +110,32 @@ class PushNotificationService {String buttonsJson = messageData["buttons"];if (buttonsJson != null && buttonsJson.isNotEmpty) {buttons = List.from(jsonDecode(buttonsJson)).map((e) => AlertButton.fromJson(e)).toList();+ confirmButton = buttons.firstWhere((element) => element.action != null, orElse: () => null);+ declineButton = buttons.firstWhere((element) => element.action == null, orElse: () => null);}}- AwesomeDialog(- context: _context,- dialogType: DialogType.INFO,- animType: AnimType.BOTTOMSLIDE,- title: title,- desc: body,- btnOkText: buttons != null && buttons.isNotEmpty ? buttons[0].title : "Ok",- btnCancelText: buttons != null && buttons.isNotEmpty ? buttons[1].title : null,- btnOkOnPress: () async {- if (buttons != null && buttons.isNotEmpty) {- performAlertAction(buttons[0].action);- }- else if (action!= null) {- performAlertAction(action);- }- },- btnCancelOnPress: () {- if (buttons != null && buttons.isNotEmpty) {- performAlertAction(buttons[1].action);- }- }- ).show();+ if(!onResume && !onLaunch) {+ AwesomeDialog(+ context: _context,+ dialogType: DialogType.INFO,+ animType: AnimType.BOTTOMSLIDE,+ title: title,+ desc: body,+ btnOkText: confirmButton?.title ?? "Ok",+ btnCancelText: declineButton?.title,+ btnOkOnPress: confirmButton != null ? () {+ if (confirmButton != null && confirmButton.action != null) {+ performAlertAction(confirmButton.action);+ }+ else if (action != null) {+ performAlertAction(action);+ }+ } : null,+ btnCancelOnPress: declineButton != null ? () {+ } : null+ ).show();+ }}}}