Skip to content

Commit

Permalink
fix: Update lastAlarmCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Myzel394 committed Aug 3, 2023
1 parent 282b09e commit 2635fbd
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions lib/services/manager_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ Future<void> updateLocation() async {
accuracy: locationData.accuracy,
tasks: List<UpdatedTaskData>.from(
runningTasks.map(
(task) => UpdatedTaskData(
id: task.id,
name: task.name,
),
(task) =>
UpdatedTaskData(
id: task.id,
name: task.name,
),
),
),
),
Expand All @@ -112,11 +113,12 @@ Future<void> checkViewAlarms({
onTrigger: (alarm, location, __) async {
if (alarm is RadiusBasedRegionLocationAlarm) {
final flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
FlutterLocalNotificationsPlugin();

flutterLocalNotificationsPlugin.show(
int.parse(
"${location.createdAt.millisecond}${location.createdAt.microsecond}"),
"${location.createdAt.millisecond}${location.createdAt
.microsecond}"),
StringUtils.truncate(
l10n.locationAlarm_radiusBasedRegion_notificationTitle_whenEnter(
view.name,
Expand All @@ -130,7 +132,7 @@ Future<void> checkViewAlarms({
AndroidChannelIDs.locationAlarms.name,
l10n.androidNotificationChannel_locationAlarms_name,
channelDescription:
l10n.androidNotificationChannel_locationAlarms_description,
l10n.androidNotificationChannel_locationAlarms_description,
importance: Importance.max,
priority: Priority.max,
),
Expand All @@ -151,11 +153,15 @@ Future<void> checkViewAlarms({

if (alarm is RadiusBasedRegionLocationAlarm) {
final flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
FlutterLocalNotificationsPlugin();

flutterLocalNotificationsPlugin.show(
int.parse(
"${DateTime.now().millisecond}${DateTime.now().microsecond}"),
"${DateTime
.now()
.millisecond}${DateTime
.now()
.microsecond}"),
StringUtils.truncate(
l10n.locationAlarm_radiusBasedRegion_notificationTitle_whenEnter(
view.name,
Expand All @@ -172,7 +178,7 @@ Future<void> checkViewAlarms({
alarm.zoneName,
),
channelDescription:
l10n.androidNotificationChannel_locationAlarms_description,
l10n.androidNotificationChannel_locationAlarms_description,
importance: Importance.max,
priority: Priority.max,
),
Expand All @@ -189,6 +195,8 @@ Future<void> checkViewAlarms({
},
);
}

await viewService.save();
}

Future<void> _checkViewAlarms() async {
Expand Down Expand Up @@ -367,14 +375,14 @@ Future<void> configureBackgroundFetch() async {
startOnBoot: true,
stopOnTerminate: false,
),
(taskId) async {
(taskId) async {
// We only use one taskId to update the location for all tasks,
// so we don't need to check the taskId.
await runHeadlessTask();

BackgroundFetch.finish(taskId);
},
(taskId) {
(taskId) {
// Timeout, we need to finish immediately.
BackgroundFetch.finish(taskId);
},
Expand Down

0 comments on commit 2635fbd

Please sign in to comment.