It’s common on mobile devices for the operating system to suspend the execution of apps when they are not visible to the user (in the background, for example). Suspending such apps helps preserve resources and provides better security. For an app that relies on using the device location, be aware that background apps won’t receive location updates from the system without additional configuration by the developer. If your app needs location updates while running in the background, you can configure it so the system will not suspend your app while location services are active.

When to use background location tracking
For most mobile apps, location updates are only needed when the app is in the foreground. For example, a navigation app that provides turn-by-turn directions only needs to know the user’s location when the app is open. In this case, you can use the default behavior of the operating system to suspend the app when it is not visible to the user.
However, some scenarios require location tracking even when the app is in the background.
For example, apps may need constant location updates when doing things like:
- Recording the user’s path while hiking, running, or cycling
- Tracking a mobile worker’s location relative to a geofence
- Providing location-based notifications or alerts
Configure background location tracking
Android and iOS use different mechanisms to allow apps to receive location updates when they are not visible to the user. For each platform, you need to configure additional permissions for your Flutter app.
Android requires the use of a foreground service to track location in the background. Foreground services permit your app to asynchronously perform operations that are noticeable to the user (a status bar notification let users know that your app is executing an operation and consuming system resources).
The following prerequisites must be satisfied before you are able to receive location events in the background:
-
Ensure
SystemLocationDataSource.backgroundUpdatesEnabledis set totrue. -
Add the following location permissions to the
AndroidManifest.xml:android/app/src/main/AndroidManifest.xml<manifest xmlns:android="http://schemas.android.com/apk/res/android"><uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /><uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /><applicationandroid:label="flutter_project_template"android:name="${applicationName}"android:icon="@mipmap/ic_launcher">{/* ... */}To learn more about requesting user authorization, see the Note in the Location data sources section of the Device location guide topic.
If you need background location updates in your iOS app, you can update your project to add the background mode capability.
The following prerequisites must be satisfied before you are able to receive location events in the background:
-
Ensure
SystemLocationDataSource.backgroundUpdatesEnabledis set totrue. -
The app must request authorization from the user to access the device location while it is in the background. You can do this by adding location property list keys such as
NSLocationAlwaysAndWhenInUseUsageDescription, to your project’splistfile.Info.plist<key>UIBackgroundModes</key><array><string>location</string></array><key>NSLocationAlwaysAndWhenInUseUsageDescription</key><string>This app requires background location updates for tracking your position.</string><key>NSLocationWhenInUseUsageDescription</key><string>This app needs access to location when open.</string>
To learn more about requesting user authorization, see the Note in the Location data sources section of the Device location guide topic.