fix headless task

This commit is contained in:
hihihaha
2023-06-10 21:46:53 +02:00
parent fe03554fbf
commit 27ef942723
2 changed files with 8 additions and 37 deletions

View File

@@ -136,14 +136,20 @@ Widget errorBuilder(FlutterErrorDetails details) {
), (String taskId) async { // <-- Event handler
print("[BackgroundFetch] Event received $taskId");
NotificationsHelper().backgroundJob();
BackgroundFetch.finish(taskId);
}, (String taskId) async { // <-- Task timeout handler.
print("[BackgroundFetch] TASK TIMEOUT taskId: $taskId");
BackgroundFetch.finish(taskId);
});
print('[BackgroundFetch] configure success: $status');
BackgroundFetch.scheduleTask(TaskConfig(
taskId: "com.transistorsoft.refilcnotification",
delay: 900000, // 15 minutes
periodic: true,
forceAlarmManager: true,
stopOnTerminate: false,
enableHeadless: true
));
}
@pragma('vm:entry-point')