Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Prevent app from asking "always" location permission when NSLocationAlwaysUsageDescription key is added. #305

Closed
pierregoutheraud opened this issue Apr 30, 2019 · 3 comments

Comments

@pierregoutheraud
Copy link

pierregoutheraud commented Apr 30, 2019

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 ?

  • React-Native version: 0.59.6
  • Platform: iOS
  • react-native-permissions version: 1.1.1
@natioskar
Copy link

natioskar commented May 20, 2019

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

@pierregoutheraud
Copy link
Author

It works. Thanks :-)

@HugoGresse
Copy link

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 })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants