react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

iOS Background location popup keeps on appearing when locationAuthorizationRequest: 'Always' is configured

Open Shubhangigovil opened this issue 3 years ago • 2 comments

  • 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: Simulator Screen Shot - iPhone 13 - 2022-10-05 at 14 23 43

Shubhangigovil avatar Oct 05 '22 08:10 Shubhangigovil

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.

christocracy avatar Oct 05 '22 13:10 christocracy

@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 ...

imjamescrain avatar Nov 27 '22 22:11 imjamescrain

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Jun 05 '24 01:06 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Jun 19 '24 01:06 github-actions[bot]