You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[✓] Flutter (Channel beta, 3.17.0-0.0.pre, on macOS 14.1.1 23B81 darwin-arm64, locale en-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.1)
[✓] VS Code (version 1.85.0)
[✓] Connected device (4 available)
[!] Network resources
✗ A network error occurred while checking "https://maven.google.com/": Operation timed out
! Doctor found issues in 1 category.
Plugin config
// [Android-only] This "Headless Task" is run when the Android app is terminated with `enableHeadless: true`// Be sure to annotate your callback function to avoid issues in release mode on Flutter >= 3.3.0@pragma('vm:entry-point')
voidbackgroundFetchHeadlessTask(HeadlessTask task) async {
String taskId = task.taskId;
bool isTimeout = task.timeout;
if (isTimeout) {
// This task has exceeded its allowed running-time.// You must stop what you're doing and immediately .finish(taskId)print("[BackgroundFetch] Headless task timed-out: $taskId");
// notifyTimeOut();BackgroundFetch.finish(taskId);
return;
}
checkBlockedBatch();
print('[BackgroundFetch] Headless event received.');
// Do your work here...BackgroundFetch.finish(taskId);
}
...
BackgroundFetch.registerHeadlessTask(backgroundFetchHeadlessTask);
runApp(MyApp());
...
voidinitState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.Future<void> initPlatformState() async {
if (Platform.isAndroid) {
// Configure BackgroundFetch.awaitBackgroundFetch.configure(
BackgroundFetchConfig(
minimumFetchInterval:15,
startOnBoot:true,
stopOnTerminate:false,
enableHeadless:true,
requiresBatteryNotLow:false,
requiresCharging:false,
requiresStorageNotLow:false,
requiresDeviceIdle:false,
requiredNetworkType:NetworkType.NONE), (String taskId) async {
// <-- Event handler// This is the fetch-event callback.print("[BackgroundFetch] Event received $taskId");
checkBlockedBatch();
// IMPORTANT: You must signal completion of your task or the OS can punish your app// for taking too long in the background.BackgroundFetch.finish(taskId);
}, (String taskId) async {
// <-- Task timeout handler.// This task has exceeded its allowed running-time. You must stop what you're doing and immediately .finish(taskId)// notifyTimeOut();print("[BackgroundFetch] TASK TIMEOUT taskId: $taskId");
BackgroundFetch.finish(taskId);
});
} elseif (Platform.isIOS) {
BackgroundFetch.configure(BackgroundFetchConfig(minimumFetchInterval:15),
(String taskId) async {
// <-- Event callback.// This is the fetch-event callback.print("[BackgroundFetch] taskId: $taskId");
// Use a switch statement to route task-handling.// switch (taskId) {// case 'com.transistorsoft.customtask':// print("Received custom task");// break;// default:// print("Default fetch task");// }checkBlockedBatch();
BackgroundFetch.finish(
taskId); // <-- Disable .finish(taskId) when simulating an iOS task timeout
}, (String taskId) async {
// <-- Event timeout callback// This task has exceeded its allowed running-time. You must stop what you're doing and immediately .finish(taskId)// notifyTimeOut();print("[BackgroundFetch] TIMEOUT taskId: $taskId");
BackgroundFetch.finish(taskId);
});
}
checkBlockedBatch is going to notify issues
To Reproduce
Steps to reproduce the behavior:
when app is on background ,everything is fine
I can get notification every 15 minutes, but when app is terminated , it not work
The text was updated successfully, but these errors were encountered:
Your Environment: android
flutter info
,flutter doctor
):checkBlockedBatch is going to notify issues
To Reproduce
Steps to reproduce the behavior:
I can get notification every 15 minutes, but when app is terminated , it not work
The text was updated successfully, but these errors were encountered: