Hi,
I only want to use "when in use" location permission but if I understand well, Apple forces me to also add NSLocationAlwaysUsageDescription key in Info.plist even if I am not using it.
When using the request code, the app display the right "when in use" dialog.
const permission = await Permissions.request("location", {
type: "whenInUse",
});
The problem is that if I added NSLocationAlwaysUsageDescription key, as soon as I am using navigator.geolocation.getCurrentPosition the app also requests the "always" location permission.
This only happens when testing on a real device.
On the simulator it only asks for the "when in use" permission.
Is there a way to prevent that ?
try to init the react-native geolocation with your required configuration using this line -
navigator.geolocation.setRNConfiguration({ skipPermissionRequests: true });
This will prevent the automatic permission request and you will have to manage the permission yourself
It works. Thanks :-)
for other reading this, use this if you are using the geolocation from react native community (geolocation has moved out of rn core)
import Geolocation from '@react-native-community/geolocation'
Geolocation.setRNConfiguration({ skipPermissionRequests: true })
Most helpful comment
try to init the react-native geolocation with your required configuration using this line -
navigator.geolocation.setRNConfiguration({ skipPermissionRequests: true });This will prevent the automatic permission request and you will have to manage the permission yourself