3
votes

I'm trying to get the location of my user on iOS using React Native. I have added the location privacy description in the plist, and I have tried various codes but none show the dialogue asking permission. Right now, I'm using this library: https://github.com/yonahforst/react-native-permissions

My code to request location permission is as follows:

componentDidMount() {
  Permissions.request('location', 'whenInUse')
  .then(res => {
    console.log(res);
 })

This does nothing. When I check the permission, it says undetermined.

Please note that my app does show up on the location privacy settings.

2

2 Answers

14
votes

Came across the same issue using react-native 0.48.3 iOS 11.1 and the solution was adding all existing location permissions to Info.plist

<key>NSLocationAlwaysUsageDescription</key>
<string>some string</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>some string</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>some string</string>
<key>NSLocationUsageDescription</key>
<string>some string</string>

This shows the dialogue and also works on iPhone simulator

0
votes

In case anyone else comes across this,

my problem was fixed when I ran it on my device. For some reason, the simulator does not ask any permission and nothing goes forward.