Some days ago i have same problem.At last i use background_location_tracker: ^1.6.1.It helps me a lot.In android it has param as trackingInterval.But ios has not.
@pragma('vm:entry-point')
void backgroundCallback() {
BackgroundLocationTrackerManager.handleBackgroundUpdated((data) async {
// do some stuff with data
});
}
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await BackgroundLocationTrackerManager.initialize(
backgroundCallback,
config: const BackgroundLocationTrackerConfig(
loggingEnabled: true,
androidConfig: AndroidConfig(
notificationIcon: 'explore',
trackingInterval: Duration(seconds: 30),
distanceFilterMeters: null,
),
iOSConfig: IOSConfig(
activityType: ActivityType.FITNESS,
distanceFilterMeters: null,
restartAfterKill: true,
),
),
);
}
Also flutter_background_service has limit for ios which described below:
Service terminated when app is in background (minimized) on iOS #
Keep in your mind, iOS doesn't have a long running service feature like Android. So, it's not possible to keep your application running when it's in background because the OS will suspend your application soon. Currently, this plugin provide onBackground method, that will be executed periodically by Background Fetch capability provided by iOS. It cannot be faster than 15 minutes and only alive about 15-30 seconds.