no message

merge-update-with-lab-changes
Zohaib Kambrani 5 years ago
parent 8d5d55a150
commit c10d024700

@ -93,9 +93,18 @@ class HMG_Geofence {
static void transitionTrigger(List<String> id, Location location, GeofenceEvent event) async {
id.forEach((element) {
final SendPort send = IsolateNameServer.lookupPortByName(_isolatePortName);
send?.send(event.toString());
LocalNotification.showNow(
title: "GeofenceEvent: ${event.toString()}",
subtitle: element,
onClickNotification: (payload) {
debugPrint(payload);
},
payload: element);
});
// id.forEach((element) {
// final SendPort send = IsolateNameServer.lookupPortByName(_isolatePortName);
// send?.send({"event": event, "geofence_id": element});
// });
}
void _registerIsolatePort() {
@ -103,18 +112,38 @@ class HMG_Geofence {
AppSharedPreferences pref = AppSharedPreferences();
var jsonString = pref.getString(HMG_GEOFENCES);
List jsonList = json.decode(jsonString);
jsonList.forEach((element) {
})
List<GeoZonesResponseModel> geoList = jsonList.map((e) => GeoZonesResponseModel().fromJson(e));
port.listen((dynamic data) {
GeofenceEvent event = data["event"];
String geofence_id = data["geofence_id"];
GeoZonesResponseModel geofence = _findByGeofenceIdFrom(geoList, geofence_id);
LocalNotification.showNow(
title: "HMG-Geofence",
subtitle: element,
title: "GeofenceEvent: ${_nameOf(event)}",
subtitle: geofence.description,
onClickNotification: (payload) {
debugPrint(payload);
},
payload: "Zohaib Kambrani");
payload: json.encode(geofence.toJson()));
});
}
GeoZonesResponseModel _findByGeofenceIdFrom(List<GeoZonesResponseModel> list, String geofence_id) {
var have = list.where((element) => element.geofenceId() == geofence_id).toList().first;
return have;
}
String _nameOf(GeofenceEvent event) {
if (event == GeofenceEvent.exit) {
return "Exit";
} else if (event == GeofenceEvent.enter) {
return "Enter";
} else if (event == GeofenceEvent.dwell) {
return "Well";
} else {
event.toString();
}
}
}

Loading…
Cancel
Save