Files
Jonas Acker 9d0e0852cf fix(ios): BikeControl no longer crashes at launch on some iPads
flutter_foreground_task registers a BGTaskScheduler refresh task from its
didFinishLaunching hook. With UIScene, Flutter forwards that hook from the
scene's FlutterViewController, which can be after the app finished
launching, and BGTaskScheduler then throws (App Store crash, 7.3.0, iPad on
iOS 16.6.1). BikeControl only uses the package on Android, for the screen
recording foreground service, and never declared the refresh task.

The plugin is vendored at 9.2.2 under packages/flutter_foreground_task and
now registers and schedules the refresh task only if the host Info.plist
lists it in BGTaskSchedulerPermittedIdentifiers. 11.0.3 still registers
unconditionally from didFinishLaunching, so upgrading would not fix it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 18:13:21 +02:00

45 lines
1.3 KiB
Dart

import 'flutter_foreground_task.dart';
/// A class that implements a task handler.
abstract class TaskHandler {
/// Called when the task is started.
Future<void> onStart(DateTime timestamp, TaskStarter starter);
/// Called based on the eventAction set in [ForegroundTaskOptions].
///
/// - .nothing() : Not use onRepeatEvent callback.
/// - .once() : Call onRepeatEvent only once.
/// - .repeat(interval) : Call onRepeatEvent at milliseconds interval.
void onRepeatEvent(DateTime timestamp);
/// Called when the task is destroyed.
Future<void> onDestroy(DateTime timestamp, bool isTimeout);
/// Called when data is sent using [FlutterForegroundTask.sendDataToTask].
void onReceiveData(Object data) {}
/// Called when the notification button is pressed.
void onNotificationButtonPressed(String id) {}
/// Called when the notification itself is pressed.
void onNotificationPressed() {}
/// Called when the notification itself is dismissed.
///
/// - AOS: only work Android 14+
///
/// - iOS: only work iOS 12+
void onNotificationDismissed() {}
}
/// The starter that started the task.
enum TaskStarter {
/// The task has been started by the developer.
developer,
/// The task has been started by the system.
system;
static TaskStarter fromIndex(int index) => TaskStarter.values[index];
}