flutter_background_fetch
flutter_background_fetch copied to clipboard
[BUG] [HeadlessTask] waiting for client to initialize
Your Environment
-
Plugin version: ^4.3.3
-
Platform: Android
-
flutter 2.10.0
-
Device manufacturer / model: SAMSUMG A70
-
Plugin config
void backgroundFetchHeadlessTask(HeadlessTask task) async {
var taskId = task.taskId;
var timeout = task.timeout;
if (timeout) {
print("[BackgroundFetch] Headless task timed-out: $taskId");
BackgroundFetch.finish(taskId);
return;
}
print("[BackgroundFetch] Headless event received: $taskId");
if (taskId == 'com.deltaxlat.appdriver') {
addLocalGpsHeadLess();
}
if (taskId == 'com.deltaxlat.appdriver.tasks') {
syncHeadlessTasks();
}
if (taskId == 'com.deltaxlat.appdriver.multipoint') {
syncHeadlessTasksMultipoint();
}
if (taskId == 'com.deltaxlat.appdriver.locations') {
syncHeadlessCheckPoints();
}
BackgroundFetch.finish(taskId);
}
await BackgroundFetch.configure(
BackgroundFetchConfig(
minimumFetchInterval: 60,
forceAlarmManager: false,
stopOnTerminate: false,
startOnBoot: true,
enableHeadless: true,
requiresBatteryNotLow: false,
requiresCharging: false,
requiresStorageNotLow: false,
requiresDeviceIdle: false,
requiredNetworkType: NetworkType.NONE,
), (String taskId) async {
if (taskId == 'com.deltaxlat.appdriver') {
addLocalGps();
}
if (taskId == 'com.deltaxlat.appdriver.tasks') {
syncTasks();
}
if (taskId == 'com.deltaxlat.appdriver.locations') {
syncCheckPoints();
}
if (taskId == 'com.deltaxlat.appdriver.multipoint') {
syncTasksMultipoint();
}
BackgroundFetch.finish(taskId);
}, (String taskId) async {
BackgroundFetch.finish(taskId);
});
await BackgroundFetch.scheduleTask(TaskConfig(
taskId: "com.deltaxlat.appdriver",
delay: 1800000,
periodic: true,
forceAlarmManager: false,
stopOnTerminate: false,
requiredNetworkType: NetworkType.NONE,
startOnBoot: true,
enableHeadless: true,
));
await BackgroundFetch.scheduleTask(TaskConfig(
taskId: "com.deltaxlat.appdriver.tasks",
delay: 60000,
periodic: true,
forceAlarmManager: true,
startOnBoot: true,
requiredNetworkType: NetworkType.ANY,
stopOnTerminate: false,
enableHeadless: true,
));
await BackgroundFetch.scheduleTask(TaskConfig(
taskId: "com.deltaxlat.appdriver.locations",
delay: 60000,
periodic: true,
requiredNetworkType: NetworkType.ANY,
forceAlarmManager: true,
stopOnTerminate: false,
startOnBoot: true,
enableHeadless: true,
));
await BackgroundFetch.scheduleTask(TaskConfig(
taskId: "com.deltaxlat.appdriver.multipoint",
delay: 60000,
periodic: true,
requiredNetworkType: NetworkType.ANY,
forceAlarmManager: true,
stopOnTerminate: false,
startOnBoot: true,
enableHeadless: true,
));
await bg.BackgroundGeolocation.ready(
bg.Config(
locationUpdateInterval: 60000,
persistMode: bg.Config.PERSIST_MODE_GEOFENCE,
desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
distanceFilter: 10000.0,
enableHeadless: true,
stopOnTerminate: false,
startOnBoot: true,
notification: bg.Notification(
smallIcon: "drawable/ic_launcher_notification",
priority: bg.Config.NOTIFICATION_PRIORITY_HIGH,
sticky: true,
title: user.profile?.firstName?.trim() != null ? '${user.profile?.firstName?.trim()} tienes una operación en curso' : "Operación en curso",
strings: {},
layout: "",
actions: [],
text: 'Recuerda completar todas tus tareas.',
),
showsBackgroundLocationIndicator: true,
backgroundPermissionRationale: bg.PermissionRationale(
title: "Permitir que DeltaX acceda a la ubicación de este dispositivo incluso cuando esté cerca o no esté en uso?",
message: "DeltaX recopila datos de tu ubicación, para realizar seguimiento a las cargas que transportas",
positiveAction: "Cambiar a 'Permitir todo el tiempo'",
negativeAction: "Cancelar",
),
locationAuthorizationRequest: 'Always',
debug: false,
),
);
await bg.BackgroundGeolocation.start();
// bg.BackgroundGeolocation.setConfig(config)
await BackgroundFetch.start();
Debug logs
- Android:
$ adb logcat
02-24 16:18:42.181 25004 25004 D TSBackgroundFetch: [BGTask] timeout: com.deltaxlat.appdriver.locations
02-24 16:18:42.195 25004 25004 D TSBackgroundFetch: 💀 [HeadlessTask com.deltaxlat.appdriver.locations]
02-24 16:18:42.196 25004 25004 D TSBackgroundFetch: [BGTask] timeout: com.deltaxlat.appdriver.multipoint
02-24 16:18:42.209 25004 25004 D TSBackgroundFetch: 💀 [HeadlessTask com.deltaxlat.appdriver.multipoint]
02-24 16:18:42.210 25004 25004 D TSBackgroundFetch: [HeadlessTask] waiting for client to initialize
02-24 16:18:42.210 25004 25004 D TSBackgroundFetch: [HeadlessTask] waiting for client to initialize
02-24 16:18:42.210 25004 25004 D TSBackgroundFetch: [HeadlessTask] waiting for client to initialize
02-24 16:18:58.373 25004 25004 D TSBackgroundFetch: - Background Fetch event received: com.deltaxlat.appdriver.tasks
02-24 16:18:58.384 25004 25004 D TSBackgroundFetch: 💀 [HeadlessTask com.deltaxlat.appdriver.tasks]
02-24 16:18:58.384 25004 25004 D TSBackgroundFetch: [HeadlessTask] waiting for client to initialize
02-24 16:18:58.392 25004 25004 D TSBackgroundFetch: - Background Fetch event received: com.deltaxlat.appdriver.locations
02-24 16:18:58.399 25004 25004 D TSBackgroundFetch: 💀 [HeadlessTask com.deltaxlat.appdriver.locations]
02-24 16:18:58.399 25004 25004 D TSBackgroundFetch: [HeadlessTask] waiting for client to initialize
02-24 16:19:00.043 25004 25004 D TSBackgroundFetch: [BGTask] timeout: com.deltaxlat.appdriver.tasks
02-24 16:19:00.047 25004 25004 D TSBackgroundFetch: 💀 [HeadlessTask com.deltaxlat.appdriver.tasks]
02-24 16:19:00.048 25004 25004 D TSBackgroundFetch: [HeadlessTask] waiting for client to initialize
02-24 16:19:00.062 25004 25004 D TSBackgroundFetch: [BGTask] timeout: com.deltaxlat.appdriver.locations
02-24 16:19:00.066 25004 25004 D TSBackgroundFetch: 💀 [HeadlessTask com.deltaxlat.appdriver.locations]
02-24 16:19:00.068 25004 25004 D TSBackgroundFetch: [HeadlessTask] waiting for client to initialize
02-24 16:19:00.080 25004 25004 D TSBackgroundFetch: [BGTask] timeout: com.deltaxlat.appdriver.multipoint
02-24 16:19:00.084 25004 25004 D TSBackgroundFetch: 💀 [HeadlessTask com.deltaxlat.appdriver.multipoint]
02-24 16:19:00.092 25004 25004 D TSBackgroundFetch: [HeadlessTask] waiting for client to initialize
02-24 16:19:00.359 25004 25004 D TSBackgroundFetch: - Background Fetch event received: com.deltaxlat.appdriver.multipoint
02-24 16:19:00.365 25004 25004 D TSBackgroundFetch: 💀 [HeadlessTask com.deltaxlat.appdriver.multipoint]
02-24 16:19:00.365 25004 25004 D TSBackgroundFetch: [HeadlessTask] waiting for client to initialize
02-24 16:07:43.997 9956 9956 D TSBackgroundFetch: - configure
02-24 16:07:43.997 9956 9956 D TSBackgroundFetch: - start
02-24 16:07:43.997 9956 9956 D TSBackgroundFetch: - registerTask: flutter_background_fetch
02-24 16:07:44.000 9956 9956 D TSBackgroundFetch: {
02-24 16:07:44.000 9956 9956 D TSBackgroundFetch: "taskId": "flutter_background_fetch",
02-24 16:07:44.000 9956 9956 D TSBackgroundFetch: "isFetchTask": true,
02-24 16:07:44.000 9956 9956 D TSBackgroundFetch: "minimumFetchInterval": 60,
02-24 16:07:44.000 9956 9956 D TSBackgroundFetch: "stopOnTerminate": false,
02-24 16:07:44.000 9956 9956 D TSBackgroundFetch: "requiredNetworkType": 0,
02-24 16:07:44.000 9956 9956 D TSBackgroundFetch: "requiresBatteryNotLow": false,
02-24 16:07:44.000 9956 9956 D TSBackgroundFetch: "requiresCharging": false,
02-24 16:07:44.000 9956 9956 D TSBackgroundFetch: "requiresDeviceIdle": false,
02-24 16:07:44.000 9956 9956 D TSBackgroundFetch: "requiresStorageNotLow": false,
02-24 16:07:44.000 9956 9956 D TSBackgroundFetch: "startOnBoot": true,
02-24 16:07:44.000 9956 9956 D TSBackgroundFetch: "jobService": "com.transistorsoft.flutter.backgroundfetch.HeadlessTask",
02-24 16:07:44.000 9956 9956 D TSBackgroundFetch: "forceAlarmManager": false,
02-24 16:07:44.000 9956 9956 D TSBackgroundFetch: "periodic": true,
02-24 16:07:44.000 9956 9956 D TSBackgroundFetch: "delay": -1
02-24 16:07:44.000 9956 9956 D TSBackgroundFetch: }
02-24 16:07:44.039 9956 9956 D TSBackgroundFetch: - registerTask: com.deltaxlat.appdriver
02-24 16:07:44.039 9956 9956 D TSBackgroundFetch: {
02-24 16:07:44.039 9956 9956 D TSBackgroundFetch: "taskId": "com.deltaxlat.appdriver",
02-24 16:07:44.039 9956 9956 D TSBackgroundFetch: "isFetchTask": false,
02-24 16:07:44.039 9956 9956 D TSBackgroundFetch: "minimumFetchInterval": 15,
02-24 16:07:44.039 9956 9956 D TSBackgroundFetch: "stopOnTerminate": false,
02-24 16:07:44.039 9956 9956 D TSBackgroundFetch: "requiredNetworkType": 0,
02-24 16:07:44.039 9956 9956 D TSBackgroundFetch: "requiresBatteryNotLow": false,
02-24 16:07:44.039 9956 9956 D TSBackgroundFetch: "requiresCharging": false,
02-24 16:07:44.039 9956 9956 D TSBackgroundFetch: "requiresDeviceIdle": false,
02-24 16:07:44.039 9956 9956 D TSBackgroundFetch: "requiresStorageNotLow": false,
02-24 16:07:44.039 9956 9956 D TSBackgroundFetch: "startOnBoot": true,
02-24 16:07:44.039 9956 9956 D TSBackgroundFetch: "jobService": "com.transistorsoft.flutter.backgroundfetch.HeadlessTask",
02-24 16:07:44.039 9956 9956 D TSBackgroundFetch: "forceAlarmManager": false,
02-24 16:07:44.039 9956 9956 D TSBackgroundFetch: "periodic": true,
02-24 16:07:44.039 9956 9956 D TSBackgroundFetch: "delay": 1800000
02-24 16:07:44.039 9956 9956 D TSBackgroundFetch: }
02-24 16:07:44.069 9956 9956 D TSBackgroundFetch: - registerTask: com.deltaxlat.appdriver.tasks
02-24 16:07:44.069 9956 9956 D TSBackgroundFetch: {
02-24 16:07:44.069 9956 9956 D TSBackgroundFetch: "taskId": "com.deltaxlat.appdriver.tasks",
02-24 16:07:44.069 9956 9956 D TSBackgroundFetch: "isFetchTask": false,
02-24 16:07:44.069 9956 9956 D TSBackgroundFetch: "minimumFetchInterval": 15,
02-24 16:07:44.069 9956 9956 D TSBackgroundFetch: "stopOnTerminate": false,
02-24 16:07:44.069 9956 9956 D TSBackgroundFetch: "requiredNetworkType": 1,
02-24 16:07:44.069 9956 9956 D TSBackgroundFetch: "requiresBatteryNotLow": false,
02-24 16:07:44.069 9956 9956 D TSBackgroundFetch: "requiresCharging": false,
02-24 16:07:44.069 9956 9956 D TSBackgroundFetch: "requiresDeviceIdle": false,
02-24 16:07:44.069 9956 9956 D TSBackgroundFetch: "requiresStorageNotLow": false,
02-24 16:07:44.069 9956 9956 D TSBackgroundFetch: "startOnBoot": true,
02-24 16:07:44.069 9956 9956 D TSBackgroundFetch: "jobService": "com.transistorsoft.flutter.backgroundfetch.HeadlessTask",
02-24 16:07:44.069 9956 9956 D TSBackgroundFetch: "forceAlarmManager": true,
02-24 16:07:44.069 9956 9956 D TSBackgroundFetch: "periodic": true,
02-24 16:07:44.069 9956 9956 D TSBackgroundFetch: "delay": 60000
02-24 16:07:44.069 9956 9956 D TSBackgroundFetch: }
02-24 16:07:44.119 9956 9956 D TSBackgroundFetch: - registerTask: com.deltaxlat.appdriver.locations
02-24 16:07:44.119 9956 9956 D TSBackgroundFetch: {
02-24 16:07:44.119 9956 9956 D TSBackgroundFetch: "taskId": "com.deltaxlat.appdriver.locations",
02-24 16:07:44.119 9956 9956 D TSBackgroundFetch: "isFetchTask": false,
02-24 16:07:44.119 9956 9956 D TSBackgroundFetch: "minimumFetchInterval": 15,
02-24 16:07:44.119 9956 9956 D TSBackgroundFetch: "stopOnTerminate": false,
02-24 16:07:44.119 9956 9956 D TSBackgroundFetch: "requiredNetworkType": 1,
02-24 16:07:44.119 9956 9956 D TSBackgroundFetch: "requiresBatteryNotLow": false,
02-24 16:07:44.119 9956 9956 D TSBackgroundFetch: "requiresCharging": false,
02-24 16:07:44.119 9956 9956 D TSBackgroundFetch: "requiresDeviceIdle": false,
02-24 16:07:44.119 9956 9956 D TSBackgroundFetch: "requiresStorageNotLow": false,
02-24 16:07:44.119 9956 9956 D TSBackgroundFetch: "startOnBoot": true,
02-24 16:07:44.119 9956 9956 D TSBackgroundFetch: "jobService": "com.transistorsoft.flutter.backgroundfetch.HeadlessTask",
02-24 16:07:44.119 9956 9956 D TSBackgroundFetch: "forceAlarmManager": true,
02-24 16:07:44.119 9956 9956 D TSBackgroundFetch: "periodic": true,
02-24 16:07:44.119 9956 9956 D TSBackgroundFetch: "delay": 60000
02-24 16:07:44.119 9956 9956 D TSBackgroundFetch: }
02-24 16:14:26.321 25004 25004 D TSBackgroundFetch: - start
02-24 16:14:26.322 25004 25004 D TSBackgroundFetch: - registerTask: flutter_background_fetch
02-24 16:14:26.322 25004 25004 D TSBackgroundFetch: {
02-24 16:14:26.322 25004 25004 D TSBackgroundFetch: "taskId": "flutter_background_fetch",
02-24 16:14:26.322 25004 25004 D TSBackgroundFetch: "isFetchTask": true,
02-24 16:14:26.322 25004 25004 D TSBackgroundFetch: "minimumFetchInterval": 60,
02-24 16:14:26.322 25004 25004 D TSBackgroundFetch: "stopOnTerminate": false,
02-24 16:14:26.322 25004 25004 D TSBackgroundFetch: "requiredNetworkType": 0,
02-24 16:14:26.322 25004 25004 D TSBackgroundFetch: "requiresBatteryNotLow": false,
02-24 16:14:26.322 25004 25004 D TSBackgroundFetch: "requiresCharging": false,
02-24 16:14:26.322 25004 25004 D TSBackgroundFetch: "requiresDeviceIdle": false,
02-24 16:14:26.322 25004 25004 D TSBackgroundFetch: "requiresStorageNotLow": false,
02-24 16:14:26.322 25004 25004 D TSBackgroundFetch: "startOnBoot": true,
02-24 16:14:26.322 25004 25004 D TSBackgroundFetch: "jobService": "com.transistorsoft.flutter.backgroundfetch.HeadlessTask",
02-24 16:14:26.322 25004 25004 D TSBackgroundFetch: "forceAlarmManager": false,
02-24 16:14:26.322 25004 25004 D TSBackgroundFetch: "periodic": true,
02-24 16:14:26.322 25004 25004 D TSBackgroundFetch: "delay": -1
02-24 16:14:26.322 25004 25004 D TSBackgroundFetch: }
Additional context Add any other context about the problem here.
@christocracy pls help :D
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.
Is possible run more than one scheduleTask ? I'm so confuse how can i make this.
Is possible run more than one scheduleTask
What are you trying to do?
I wanted to perform 3 activities:
- Perform requisition.
- After request to dowload.
- Perform installation of an apk silently (It will only serve for provisioned devices).
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.