backgroundPermissionRationale property

PermissionRationale? backgroundPermissionRationale
read / write

(Android 11+) Configure the dialog presented to the user when Always location permission is requested.

Just as in iOS 13/14, Android 11 has changed location authorization and no longer offers the [Allow all the time] button on the location authorization dialog. Instead, Android now offers a hook to present a custom dialog to the user where you will explain exactly why you require "Allow all the time" location permission.

This dialog can forward the user directly to your application's Location Permissions screen, where the user must explicity authorize [Allow all the time]. The Background Geolocation SDK will present this dialog, which can be customized with backgroundPermissionRationale.


 locationAuthorizationRequest: 'Always',
 backgroundPermissionRationale: PermissionRationale(
   title: "Allow {applicationName} to access to this device's location in the background?",
   message: "In order to track your activity in the background, please enable {backgroundPermissionOptionLabel} location permission",
   positiveAction: "Change to {backgroundPermissionOptionLabel}",
   negativeAction: "Cancel"

Template Tags

A limited number of template-tags are supported in each of the attributes, by wrapping with {tagName}:

Template Tag Default value Description
{backgroundPermissionOptionLabel} Allow all the time (API Level 30) Gets the localized label that corresponds to the option in settings for granting background access.
{applicationName} Your App Name Returns the localized name of your application from AndroidManifest

See also:


PermissionRationale? backgroundPermissionRationale;