react-native-permissions icon indicating copy to clipboard operation
react-native-permissions copied to clipboard

check(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE) always returns unavailable!

Open mrousavy opened this issue 6 years ago • 24 comments

Bug report

Summary

This problem has been opened here before and closed because the author forgot to add the Pods to the Podfile, but I didn't.

Everytime I run

const permissionStatus = await check(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE);

I get 'unavailable' as a result. The odd thing is, that it does work on my Simulator where it returns 'denied' at first, then I can call request. On my actual iPhone 11 device running iOS 13 it does return 'unavailable' immediately.

I have added the descriptions to Info.plist:

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>$(PRODUCT_NAME) needs your location to find items near you. A location will only be stored when you choose to by creating a post.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>$(PRODUCT_NAME) needs your location to find items near you. A location will only be stored when you choose to by creating a post.</string>

I also added both Always and WhenInUse permissions to my Podfile:

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

And I have ran pod install.

Environment info

react-native info output:

info Fetching system and libraries information...
(node:12653) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
System:
    OS: macOS 10.15.5
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 1.28 GB / 32.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.4.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.6 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 25, 28, 29
      Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.0, 30.0.0, 30.0.0
      System Images: android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
      Android NDK: 21.2.6472646
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6514223
    Xcode: 11.5/11E608c - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_252 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.0 => 0.63.0 
  npmGlobalPackages:
    *react-native*: Not Found

Library version: ^2.1.5

Steps to reproduce

  1. Add NSLocationWhenInUseUsageDescription tag to Info.plist
  2. Add Permission-LocationWhenInUse podspec to Podfile
  3. Run pod install
  4. Run app on device
  5. Call check(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE)
  6. Immediately receive unavailable for some reason

Describe what you expected to happen:

  1. I should receive denied at first so I can call request after that!

Reproducible sample code

const permissionStatus = await check(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE);

mrousavy avatar Jul 13 '20 12:07 mrousavy

And yes, I have also tested it with https://github.com/zoontek/rn-location-permission-example - same problem! It immediately returns unavailable for check().

mrousavy avatar Jul 13 '20 12:07 mrousavy

Hi. Have you checked if Location services are enabled on your device?

zoontek avatar Jul 15 '20 08:07 zoontek

Yes, location services are enabled. They're also enabled for the App specifically.

mrousavy avatar Jul 15 '20 09:07 mrousavy

Try uninstalling all applications with a similar namespace start (ex: "com.facebook") from your device, or reset your device permissions.

zoontek avatar Jul 27 '20 16:07 zoontek

I've seen "unavailable" being reported for iOS camera access permissions on my iPhone 11 Pro (running iOS 13). I'm not sure what causes it (I'm sure the camera access permission in the iOS settings menu is ON). I'm working around it by ignoring "unavailable" results for devices/permission-types where I know availability is not a concern (i.e. effectively proceeding as if access is "granted").

I don't know what could cause it, but it does seem an 'unavailable' result does not necessarily mean the feature is not available on the device.

@zoontek How do I reset the device permissions? I've tried just turning it 'OFF' and then back 'ON' but that didn't fix it.

HansBouwmeester avatar Jul 29 '20 18:07 HansBouwmeester

@Gra55h0pper Here's a tutorial https://www.addictivetips.com/ios/reset-all-app-permissions-on-ios/

zoontek avatar Jul 30 '20 13:07 zoontek

@zoontek Thanks! I tried it but it didn't make a difference.

However, I realized I forgot to add the Camera permission path to my Podfile. pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec" I haven't had a chance to try yet, but could that perhaps explain the behavior I'm seeing?

HansBouwmeester avatar Jul 31 '20 20:07 HansBouwmeester

@Gra55h0pper Yes

zoontek avatar Aug 04 '20 07:08 zoontek

Can we close this @Gra55h0pper @zoontek ?

tallpants avatar Aug 27 '20 07:08 tallpants

Is this resolved, even I am facing this similar issue?

YogeshSinghNegi avatar Sep 19 '20 12:09 YogeshSinghNegi

Same problem!! :(

oscarcornejo avatar Oct 07 '20 15:10 oscarcornejo

Same

nguyentuanit97 avatar Oct 12 '20 07:10 nguyentuanit97

  1. update pod file
permissions_path = '../node_modules/react-native-permissions/ios'

pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone"
  1. Clean cache pod cache clean --all
  2. Clean build folder XCode -> Product -> Clean build folder
  3. Run pod install

It should help

ABespolov avatar Feb 15 '21 12:02 ABespolov

FYI for those who need to change the pod file for location when in use: pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse"

lucas0205 avatar Oct 03 '21 14:10 lucas0205

I am having the same problem with the permissions, I am working with an iphone 13 with ios 15.0 the permissions of microphone, location, media library are giving "unavailable", but the permission of the camera if it is giving me option to be able to guarantee it

MrFoxxz avatar Oct 11 '21 15:10 MrFoxxz

I never understand why people post on closed issues without sufficient information to reproduce (https://stackoverflow.com/help/minimal-reproducible-example) like an App.js that would reproduce it when coupled with an npx react-native init RNPermTest and an install of react-native-permissions :thinking:

mikehardy avatar Oct 11 '21 15:10 mikehardy

@MrFoxxz were you able to figure it out why is always returning "unavailable"?

ghost avatar Oct 25 '21 18:10 ghost

@MrFoxxz were you able to figure it out why is always returning "unavailable"?

@gilsonviana-modus remove Pods, podlock, after that pod install againt. it worked for me

vanhungoz avatar Nov 10 '21 08:11 vanhungoz

Any updates on this issue, still having this.

Egehanozsoy avatar Feb 20 '22 09:02 Egehanozsoy

@Egehanozsoy please refer to my comment here https://github.com/zoontek/react-native-permissions/issues/483#issuecomment-940125938 on this issue that was closed nearly 2 years ago

mikehardy avatar Feb 20 '22 22:02 mikehardy