react-native-background-geolocation@5.0.0-beta.1
    Preparing search index...

    Interface PermissionRationale

    (Android 11+) Configure the dialog shown when requesting Always background location permission.

    Android 11 changed the location authorization flow and no longer presents an “Allow all the time” option on the initial system dialog.
    Instead, Android allows apps to show a custom rationale dialog explaining why background access is required.

    This dialog can take the user directly to the app’s Location Permissions settings screen, where they can explicitly grant Allow all the time. The SDK presents this dialog automatically when:

    Behavior Notes

    • Android presents the AppConfig.backgroundPermissionRationale dialog once only.
      After the user presses the positiveAction, it will not be shown again
      (pressing Cancel does not count as acceptance).
    • If the user later resets your app’s Location permission to Ask every time,
      the rationale dialog becomes eligible to be shown again.

    Example

    import BackgroundGeolocation from "react-native-background-geolocation";

    BackgroundGeolocation.ready({
    geolocation: {
    locationAuthorizationRequest: 'Always'
    },
    app: {
    backgroundPermissionRationale: {
    title: "Allow {applicationName} to access this device's location in the background?",
    message: "To track your activity in the background, please enable {backgroundPermissionOptionLabel} location access.",
    positiveAction: "Change to {backgroundPermissionOptionLabel}",
    negativeAction: "Cancel"
    }
    }
    });

    Template Tags

    The following template variables can be used inside any rationale field by writing them as {tagName}:

    Template Tag Default value Description
    {backgroundPermissionOptionLabel} "Allow all the time" (API 30+) Localized label for the background location permission option.
    {applicationName} App name Localized application name from AndroidManifest.

    See also

    interface PermissionRationale {
        title?: string;
        message?: string;
        positiveAction?: string;
        negativeAction?: string;
    }
    Index

    Properties

    title?: string

    Title for the Android background location permission dialog.

    message?: string

    The body text of the dialog. Provide an explanation of why you need this permission, similar in purpose to iOS' NSLocationAlwaysAndWhenInUseUsageDescription.

    positiveAction?: string

    The text to display on the positive action button.

    negativeAction?: string

    The text to display on the negative action button (eg: Cancel)