> For the complete documentation index, see [llms.txt](https://dev.pointr.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev.pointr.tech/features/indoor-location-blue-dot/background-positioning.md).

# Background Positioning

This guide explains how to enable location services for background positioning within your mobile app from your app configurations or the Pointr Cloud Dashboard.

By default, mobile apps may only use location services when they are running in the foreground.&#x20;

## Enable Background Location

### **Enable background location using the Pointr Cloud Dashboard**

{% stepper %}
{% step %}
In Pointr Cloud on the Client page, click **Edit** next to your company name.
{% endstep %}

{% step %}
Click **Advanced Configuration**.
{% endstep %}

{% step %}
In the Advanced Configuration modal, click **Add new**.&#x20;
{% endstep %}

{% step %}
Add each of the parameters listed below. Copy and paste the parameters as needed.

#### Background Positioning Parameters

<table><thead><tr><th width="247.3515625">Parameter</th><th width="284.7359619140625">Description</th><th width="92.3935546875">Type</th><th width="121.4134521484375">Example</th></tr></thead><tbody><tr><td><code>positionManagerConfiguration_isBeaconTrackingEnabledInBackground</code></td><td>Enable beacon-based background positioning</td><td>boolean</td><td>true</td></tr><tr><td><code>positionManagerConfiguration_isGpsTrackingEnabledInBackground</code></td><td>Enables background GPS</td><td>boolean</td><td>true</td></tr><tr><td><code>geofenceManagerConfiguration_betweenScanPeriodBackground</code></td><td>Android only. How long (ms) the app waits before turning on sensors when in background mode. Lower values increase accuracy and battery usage. </td><td>integer</td><td>0 (Minimum)</td></tr><tr><td><code>geofenceManagerConfiguration_scanPeriodBackground</code></td><td>Android only. How long (ms) the app keeps sensors on before turning them off again when in background mode. Higher values increase accuracy and battery usage.</td><td>integer</td><td>1100 (Maximum)</td></tr></tbody></table>
{% endstep %}
{% endstepper %}

### **Enable background location using your App Configurations**

{% tabs %}
{% tab title="iOS" %}

#### **App Configuration**

{% stepper %}
{% step %}
Enable “**Location Updates**” under “**Background modes**” inside Capabilities on xCode

```swift
let configuration = PTRMutableConfiguration()
    configuration.positionManagerConfiguration.isBeaconTrackingEnabledInBackground = true
    configuration.positionManagerConfiguration.isGpsTrackingEnabledInBackground = true
    Pointr.shared.configurationManager?.updateRuntimeConfiguration(configuration)
```

{% endstep %}

{% step %}
Add “**Privacy - Location Always Usage Description**” inside <kbd>`Info.plist`</kbd>
{% endstep %}
{% endstepper %}

**Dependencies**&#x20;

* **App Requirements:** The app must be designed to handle background location updates.
* **User Permissions**: The app must have the appropriate permissions. When an app requests location access, users can choose between three options:
  * **Allow While Using the App**: Location Access when the app is open in the foreground.
  * **Allow Once**: Location access only for the current app session.
  * **Always Allow**: Location access even when the app is running in the background, including when the phone is locked.
* **Privacy Settings**: Users must opt-in to background location updates by choosing “Always Allow” permission after initial launch. Permissions can always adjusted under the device’s privacy options if they change their mind about an app’s location access.
* **Battery Optimization**: iOS might restrict background activities like location sharing to save battery, especially when the phone is locked for extended periods.

With these conditions met, the app will receive user location even when the phone is locked.
{% endtab %}

{% tab title="Android" %}

#### **App Configuration**

By default, the Android SDK includes all the necessary permissions in the manifest to use background positioning.&#x20;

Simply request the permissions from the user, which can be done using Pointr APIs. You can then add the configuration parameters to [enable background positioning from your Pointr Cloud Dashboard](#option-1-enable-background-location-using-the-pointr-cloud-dashboard).

#### **Enable on Runtime**

If you don't want to enable the background positioning from your Pointr Cloud instance but you want to **toggle it on runtime**, you can do so **by changing the runtime configuration of the SDK:**&#x20;

```kotlin
val configuration = PTRMutableConfiguration()
    configuration.positionManagerConfiguration.isBeaconTrackingEnabledInBackground = true
    configuration.positionManagerConfiguration.isGpsTrackingEnabledInBackground = true
    Pointr.getPointr()?.configurationManager?.updateRuntimeConfiguration(configuration)    
```

{% hint style="info" %}

* Google Play reviewers often require an explanation for enabling Background Positioning in your Play Store submission.&#x20;
* Android 7+, the system does not allow stopping and starting BLE scans more than 5 times in a window of 30 seconds.
  {% endhint %}

#### **Remove Background Positioning**

**If you don't want to use background positioning**, you should remove the permission declaration from the manifest.&#x20;

* Use the code below in your AndroidManifest.xml file, inside the scope `<manifest>`, before `<application>`:

```kotlin
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" tools:node="remove" />
```

{% endtab %}
{% endtabs %}

## Background Positioning Accuracy

When running in the background, **if background location is enabled and permitted by the user**, Pointr can produce a lower accuracy output **using GPS and BLE only.**

Pointr's positioning engine uses a combination of GPS, BLE, motion sensors (gyroscope, accelerometer, barometer) for its high accuracy output.

Both iOS and Android platforms **only allow beacon or GPS data to be used when the app is running in the background.**&#x20;

*If background location is **DISABLED**:*

* :x: Heading is lost - no motion sensor data
* :x: Location is lost - no beacon or GPS data

*If background location is **ENABLED**:*

* :x: Heading is lost - no motion sensor data
* :white\_check\_mark: Location is available - beacon or GPS data available

{% hint style="info" %}
Consequently, when the app is running in the background, **battery usage is reduced** and the **accuracy is expected to be slightly lower** as the device's sensor data is not available.&#x20;

* Learn more about battery consumption and background positioning in the [**Battery Consumption**](https://dev.pointr.tech/features/indoor-location-blue-dot/hardware-specifications/battery-consumption.md) section.
* Learn more about positioning accuracy in the [**Accuracy**](https://dev.pointr.tech/features/indoor-location-blue-dot/accuracy.md) section.
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://dev.pointr.tech/features/indoor-location-blue-dot/background-positioning.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
