GuidesFlutter API ReferencesHERE SDK for Android API referencesHERE SDK for iOS API references
Guides

Enable background updates

Positioning is only available with the Navigate license.

In case you want to continue receiving location updates while the application UI is not visible on Android, you need to implement a Foreground Service. This approach informs the user that your app is actively using location in the background.

  • Permissions: Ensure you have requested and been granted ACCESS_FINE_LOCATION. The ACCESS_BACKGROUND_LOCATION permission is not required when using a foreground service for location updates.
  • Android 14+ Requirement: For apps targeting Android 14 (API level 34) or higher, you must also declare and request the FOREGROUND_SERVICE_LOCATION permission at runtime:
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
  • Foreground Service Declaration: You must declare your service in AndroidManifest.xml and specify the foregroundServiceType for apps targeting Android 12 (API level 31) or higher:
<service
	android:name=".YourForegroundLocationService"
	android:foregroundServiceType="location" >
	...
</service>

To keep the application receiving location updates when the UI is not visible, you need to start a foreground service. Remember that using a foreground service for HERE Positioning is different from requesting the background location permission. Check the Android documentation and Foreground Services documentation for more details. Note that the positioning example app may not fully demonstrate foreground service implementation for all Android versions.

Note

If your application targets Android API level 28 or lower, as long as your app already requests the permissions mentioned in the Add permissions section, you don't need to make any changes to support background updates.

If your application needs to access the device's location even when it is not running in the foreground and is not actively using a foreground service (for example, for features like geofencing that trigger actions based on location changes when the app is closed), you must request the ACCESS_BACKGROUND_LOCATION permission. This permission grants access beyond foreground use.

  • When it's Needed: This permission is only required if your app needs location access after the user navigates away from it and you are not using a foreground service to signal ongoing location use. Typical use cases include geofencing or collecting location data passively without continuous user interaction.
  • Manifest Declaration: Add the following permission to the app's AndroidManifest.xml file. This is required for apps targeting Android 10 (API level 29) or higher:
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
  • Runtime Request: Requesting background location is a multi-step process:
    1. First, request foreground location permissions (ACCESS_FINE_LOCATION).
    2. Only after foreground permission is granted, you can then separately request ACCESS_BACKGROUND_LOCATION. This often requires presenting additional UI explaining why your app needs this level of access.
  • Restrictions and Policy:
    • Granting ACCESS_BACKGROUND_LOCATION requires explicit user approval via a separate permission dialog. Users can choose to grant foreground-only access even if background access is requested.
    • Apps requesting this permission undergo stricter review on the Google Play Store. You must provide a clear and strong justification for needing background location access that aligns with permitted use cases. Failure to justify may lead to app rejection or removal.

Note

Requesting background location permission is significantly different from using a foreground service for location updates. Most use cases requiring location while the app UI isn't visible should use a foreground service instead. Check the Android documentation on background location access for detailed implementation guidance and policy requirements.

On iOS you can enable background updates by adding the following key to the app's Info.plist file:

<key>UIBackgroundModes</key>
	<array>
		<string>location</string>
        <string>processing</string>
	</array>

The "processing" mode is needed for iOS versions 13.0 and above. When added also the following is needed:

<key>BGTaskSchedulerPermittedIdentifiers</key>
    <array>
        <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    </array>

Check the iOS documentation for more details.

Remember that the user needs to be requested for authorization. Check the Add the Required Permissions section for suggestions on how to request permissions from the user.

Once the authorization is cleared, you are all set. On iOS devices, you can enable or disable location updates in the background with the LocationEngine.setBackgroundLocationAllowed() method. Also on iOS devices, you can set the visibility of the application's background location indicator with the method LocationEngine.setBackgroundLocationIndicatorVisible().

The final check for iOS devices would be to ensure that the location updates won't pause when the device is stationary by passing false to the LocationEngine.setPauseLocationUpdatesAutomatically() method.

Note

setBackgroundLocationAllowed() and setBackgroundLocationIndicatorVisible() will return LocationEngineStatus.notAllowed if the application does not have background location capabilities enabled. Otherwise, LocationEngineStatus.ok will be returned.

On Android platforms, setBackgroundLocationAllowed(), setBackgroundLocationIndicatorVisible() and setPauseLocationUpdatesAutomatically() will return LocationEngineStatus.notSupported.

In addition, it is recommended to listen to the AppLifecycleState when you have background updates enabled.