react-native-background-geolocation
react-native-background-geolocation copied to clipboard
iOS Background location popup keeps on appearing when locationAuthorizationRequest: 'Always' is configured
- Plugin version: 4.8.2
- Platform: iOS
- OS version: macOS 12.6
- Device manufacturer / model: macbook pro 2017
- React Native version (
react-native -v): 0.70.1 - Plugin config
BackgroundGeolocation.ready({
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
distanceFilter: 4, //recording a location after specified meter
stopTimeout: 5, //after the specified time, location tracking will cease
stationaryRadius: 200,
preventSuspend: true, //battery consumption high
heartbeatInterval: 60, //change to 2500,
locationAuthorizationRequest: 'Always',
locationAuthorizationAlert: {
titleWhenNotEnabled: 'Background location is not enabled',
titleWhenOff: 'Background location-services is OFF',
instructions: 'You must enable the location-services settings',
cancelButton: 'Cancel',
settingsButton: 'Settings',
},
backgroundPermissionRationale: {
// TODO: translate
title: "Allow eTA to access 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',
},
locationTimeout: 60,
debug: true, // <-- enable this hear sounds for background-geolocation life-cycle.
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
logMaxDays: 3,
maxRecordsToPersist: 100,
enableHeadless: true,
stopOnTerminate: false, // <-- Allow the background-service to continue tracking when user closes the app.
showsBackgroundLocationIndicator: true, //iOS only
startOnBoot: true, // <-- Auto start tracking when device is powered-up.
url: ApiEndpoints.clearance,
httpRootProperty: 'Filters',
locationTemplate:
'{"Latitude": <%=latitude%>, "Longitude": <%=longitude%>}',
headers: {
authorization:
Bearer ${token}, }, extras: { Email: '[email protected]', }, })
Expected Behavior
I want the app to track the location when it is in background, foreground or quit mode. And it should ask for location permission when the permission "Always" is not granted. But there is no option for configuring the Always Allow settings in iOS and neither does the OS send it by itself as described in your docs: https://transistorsoft.github.io/react-native-background-geolocation/interfaces/config.html#locationauthorizationalert
Actual Behavior
After every 1 min it gives me this popup:

But there is no option for configuring the Always Allow
You didn’t not correctly follow the iOS Setup. You made a mistake adding the .plist strings NSLocationAlwaysAndWhenInUseUsageDescription.
@Shubhangigovil for what it's worth, I was having the same issue even with the proper .plist strings added. I had to add locationAuthorizationRequest and set it to WhenInUse inside of the BackgroundGeolocation.ready({...}) config.
See this thread: https://github.com/transistorsoft/capacitor-background-geolocation/issues/14#issuecomment-902769420
Example:
BackgroundGeolocation.ready({
...
locationAuthorizationRequest: 'WhenInUse',
...
})
Hope it helps ...
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.