React-native-permissions: check(PERMISSIONS.IOS.LOCATION_ALWAYS) returns unavailable

Created on 20 Oct 2019  路  10Comments  路  Source: zoontek/react-native-permissions

Question

Hello,

After

npm install --save react-native-permissions

I added

 permissions_path = '../node_modules/react-native-permissions/ios'
 pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways.podspec"
 pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse.podspec"

to my Podfile.

Then updated info.plist with adding

  <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
  <string>YOUR TEXT</string>
  <key>NSLocationAlwaysUsageDescription</key>
  <string>YOUR TEXT</string>
  <key>NSLocationWhenInUseUsageDescription</key>
  <string>YOUR TEXT</string>

I want to check location permission for ios with

check(PERMISSIONS.IOS.LOCATION_ALWAYS)
        .then((permissionResult) => {

But it always returns unavailable on iOS 12.4 simulator.

I use now 2.0.2 as a version.
RN: 0.60.5

All 10 comments

@efecantekin Did you check #357 ?

Yes, also I see my location on simulator but check returns unavailable.

If the meaning of adding UIBackgroundModes is like
<key>UIBackgroundModes</key>
to plist, I did it.

Are location services enabled on the simulator (Settings > Privacy)?

Screenshot 2019-10-20 at 23 53 51

Does location update background mode is enable in Xcode?

Screenshot 2019-10-20 at 23 56 29

Are location services enabled on the simulator (Settings > Privacy)?

Screenshot 2019-10-20 at 23 53 51

Does location update background mode is enable in Xcode?

Screenshot 2019-10-20 at 23 56 29

Screen Shot 2019-10-21 at 00 53 09

Yes, I see custom location on map.

@efecantekin Seeing your location on the map does not mean that you have the right to use the location when the app is in background.

You need to add location in your UIBackgroundModes: https://github.com/react-native-community/react-native-permissions/blob/master/example/ios/RNPermissionsExample/Info.plist#L74

You need to add location in your UIBackgroundModes: https://github.com/react-native-community/react-native-permissions/blob/master/example/ios/RNPermissionsExample/Info.plist#L74

The point was this.

Thank you,

What if I only want to use significant location tracking feature of iOS in background and do not want to enable this UIBackgroundModes location to track locations in background? I still need the permission from user to "Always allow" but location background mode not enabled?
This used to work fine in the earlier versions of react-native-permissions.
Any Thoughts?

@apoorva-techie Indeed, I will remove the check.

Was this page helpful?
0 / 5 - 0 ratings