import { PERMISSIONS, requestMultiple } from 'react-native-permissions';
await requestMultiple([
// Requesting both as doc https://developer.android.com/develop/sensors-and-location/location/permissions#approximate-request
PERMISSIONS.ANDROID.ACCESS_COARSE_LOCATION,
PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION,
]);
const result =
multipleResult?.[PERMISSIONS.ANDROID.ACCESS_COARSE_LOCATION];
console.log(`Did grant at least approx location: ${result === 'granted'}`) // Result will be granted for either ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
Tried passing enableHighAccuracy: false, but didn't help. If ACCESS_FINE_LOCATION permission is granted, then getCurrentPosition returns the position correctly.
Environment
System: OS: macOS 14.3.1 CPU: (10) arm64 Apple M1 Pro Memory: 111.42 MB / 16.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 22.1.0 path: /opt/homebrew/bin/node Yarn: version: 1.22.22 path: ~/.nvm/versions/node/v21.7.1/bin/yarn npm: version: 10.7.0 path: /opt/homebrew/bin/npm Watchman: version: 2024.05.06.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.15.2 path: /usr/local/bin/pod SDKs: iOS SDK: Platforms:
Platforms
Android
Versions
Description
When giving only approximate location permission (ACCESS_COARSE_LOCATION)
getCurrentPosition
returns error:Reproducible Demo
Request permission with
react-native-permissions
:Get location:
Tried passing
enableHighAccuracy: false
, but didn't help. If ACCESS_FINE_LOCATION permission is granted, thengetCurrentPosition
returns the position correctly.