Background Location Permission

Background Location Access for Android 10 and Above

Android 10 and newer versions have introduced enhanced privacy controls, affecting how apps can access a user’s location in the background. This guide outlines the necessary permissions, explains Google’s changes, and describes how Netmera can assist in requesting background location access from users.

ACCESS_BACKGROUND_LOCATION

If your application needs to access the user’s location data while running in the background, you must include the ACCESS_BACKGROUND_LOCATION permission. This permission is essential for any background location tracking.

Understanding Google’s Privacy Changes

Starting with Android 10, Google introduced restrictions to improve privacy around location sharing, making it harder for apps to access location data in the background. The reasons for this change are:

  1. Privacy Enhancements

Android 10+ restricts apps from requesting background location permissions directly within the app. Users are only offered “Allow only while using the app” or “Deny” options when prompted. Google’s goal is to increase transparency and control over location data sharing.

  1. Increased User Control

Google encourages users to be more intentional about sharing their location. For apps to always have background location access, users must manually grant this permission in their settings:

Background Location Access Path for App Users:

Go to Settings > Apps > [Your App] > Permissions > Location and select “Allow always”.

How Netmera Supports Background Location Permission Requests

Netmera has implemented tools to help developers request background location access from users in a seamless way.

Using Netmera's Background Location Permission

What It Does:

Netmera has defined a Background Location Permission event, that is triggered when the application requests ACCESS_BACKGROUND_LOCATION.

How It Works:

When this event is triggered, it can activate an automation scenario to guide users through granting background location permission. For example, a widget can be configured to show users a prompt about the permission requirements.

How to Create a Background Location Permission Widget

This feature enables Netmera customers to display a widget that informs users about background location permissions. Here’s how to set it up:

Step 1: Create a Mobile Widget

Use the panel to create a widget that informs users about the need for background location access. Further information can be found on our User Documentation about how to create Widgets and Adding Click Actions.

  1. Design Your Widget

  2. Configure Button Actions

Set up two button actions:

  • Allow Permission button: Directs users to Settings > Location so they can enable “Allow always”.

  • Deny Permission button: Provides the option to decline.

Step 2: Configure the Background Location Permission Event

In your app’s code, request ACCESS_BACKGROUND_LOCATION. This will trigger the event automatically, activating any associated automations.

Step 3: Automate a Push Notification

Set up a push notification that’s triggered by the event. This can include a Handle Special Action option to prompt the user to allow background location access. Further information can be found on our User Documentation about Automation Scenarios and Handle Special Action.

Example Scenario for Automation Setup

  1. Automation Setup:

    • Begin by setting up the automation in Create New Automation section.

    • Select the Handle Special Action tab during the automation configuration.

  2. Event Selection:

    • In the Event section, choose the Background Location Permission event. This event is triggered when the background location permission is requested by the SDK.

  3. Occurrence Selection:

    • Under Occurrence, select 1. This ensures that the event is triggered once, upon the first request for background location permission.

  4. User Limit:

    • When the Background Location Permission is requested, the SDK will trigger the Background Location Permission event.

    • It’s important to set a limit for how often the widget (asking for permission) is shown to the user. This will prevent showing the widget too frequently and ensure the user experience remains positive.

    Example of widget frequency limit: Set the widget to appear no more than once per week or based on other suitable time intervals to avoid overuse.

Step 4: Users Updating Settings

When users tap the Update Setting button, the SDK redirects them to the device's settings to enable location access.

Background Location Permission Event Trigger Conditions

The event will trigger when all of the following are true:

  • The device is running Android 10 or above,

  • The app includes background location permission in the manifest,

  • The app already has foreground location permission.

If both foreground and background permissions are granted, this event will not trigger.

Last updated