Hi friend, I need some help.
I'm using the foreground + fl_location package in my iOS app to keep my background process active.
It works perfectly, but only for a short period of time, around 20 minutes, the background stops triggering the onRepeat callback, only starting again after opening the app again.
I need the background service to run for a few hours with the app minimized and the screen off, just like it happens on Android.
Could you tell me if there's something wrong with my implementation?
My code snippet is basically very similar to the example project for the foreground location.
I'm using the following for testing:
Flutter 3.37,
iPhone SE 1st generation SDK 15.8.3
FlutterForegroundTask.init(
....
foregroundTaskOptions: ForegroundTaskOptions(
eventAction: ForegroundTaskEventAction.repeat(60000),
),
....
);
class LocationServiceHandler extends TaskHandler {
StreamSubscription<Location>? _streamSubscription;
@override
Future<void> onStart(DateTime timestamp, TaskStarter starter) async {
_streamSubscription = FlLocation.getLocationStream(Location.low).listen((location) {
///nothing
});
}
@override
void onRepeatEvent(DateTime timestamp) {
myComplexMethod();
}
@override
Future<void> onDestroy(DateTime timestamp) async {
_streamSubscription?.cancel();
_streamSubscription = null;
}
}
Hi friend, I need some help.
I'm using the foreground + fl_location package in my iOS app to keep my background process active.
It works perfectly, but only for a short period of time, around 20 minutes, the background stops triggering the onRepeat callback, only starting again after opening the app again.
I need the background service to run for a few hours with the app minimized and the screen off, just like it happens on Android.
Could you tell me if there's something wrong with my implementation?
My code snippet is basically very similar to the example project for the foreground location.
I'm using the following for testing:
Flutter 3.37,
iPhone SE 1st generation SDK 15.8.3