rnmapbox / rnmapbox/maps

[Bug]: iOS requests background location permission, although it shouldn't

Open
#2,911 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
2.9k
Forks
947
Avg merge
6d 37m
Merged PRs (30d)
1

Description

Mapbox Implementation

Mapbox

Mapbox Version

default

Platform

iOS

@rnmapbox/maps version

10.0.0-beta.64

Standalone component to reproduce
import React from 'react';
import {
  MapView,
  ShapeSource,
  LineLayer,
  Camera,
  MapboxGL,
} from '@rnmapbox/maps';

const aLine = {
  type: 'LineString',
  coordinates: [
    [-74.00597, 40.71427],
    [-74.00697, 40.71527],
  ],
};

class BugReportExample extends React.Component {
  render() {
    return (
      <MapView style={{flex: 1}}>
        <Camera centerCoordinate={[-74.00597, 40.71427]} zoomLevel={14} />
        <ShapeSource id="idStreetLayer" shape={aLine}>
          <LineLayer id="idStreetLayer" />
        </ShapeSource>
          <MapboxGL.UserLocation
            requestsAlwaysUse={false}
            showsUserHeadingIndicator
            visible
          />
      </MapView>
    );
  }
}
Observed behavior and steps to reproduce

When rendering the MapboxGL.UserLocation component, on iOS there will always be a request for the background location permission, even with requestAlwaysUse explicitly set to false. The request is most likely triggered by this component, as it doesn't appear when commenting it out. I tested all scenarios after completely removing the app from iOS simulator to reset all permissions.

Expected behavior

When requestAlwaysUse is set to false (or not explicitly set), no request for background location permission appears.

Notes / preliminary analysis

No response

Additional links and references

UserLocation.md

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the standalone BugReportExample and the MapboxGL.UserLocation component on an iOS simulator, using the permission state reset described in the report. Compare behavior with requestsAlwaysUse set to false, omitted, and enabled, then verify that only the enabled case requests background location permission; use docs/UserLocation.md#requestsalwaysuse to confirm the intended option semantics.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, javascript, react-native
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.