check(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE) always returns unavailable!
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
- Add
NSLocationWhenInUseUsageDescriptiontag toInfo.plist - Add
Permission-LocationWhenInUsepodspec toPodfile - Run
pod install - Run app on device
- Call
check(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE) - Immediately receive
unavailablefor some reason
Describe what you expected to happen:
- I should receive
deniedat first so I can callrequestafter that!
Reproducible sample code
const permissionStatus = await check(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE);
And yes, I have also tested it with https://github.com/zoontek/rn-location-permission-example - same problem! It immediately returns unavailable for check().
Hi. Have you checked if Location services are enabled on your device?

Yes, location services are enabled. They're also enabled for the App specifically.
Try uninstalling all applications with a similar namespace start (ex: "com.facebook") from your device, or reset your device permissions.
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.
@Gra55h0pper Here's a tutorial https://www.addictivetips.com/ios/reset-all-app-permissions-on-ios/
@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?
@Gra55h0pper Yes
Can we close this @Gra55h0pper @zoontek ?
Is this resolved, even I am facing this similar issue?
Same problem!! :(
Same
- 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"
- Clean cache
pod cache clean --all - Clean build folder
XCode -> Product -> Clean build folder - Run
pod install
It should help
FYI for those who need to change the pod file for location when in use:
pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse"
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
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:
@MrFoxxz were you able to figure it out why is always returning "unavailable"?
@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
Any updates on this issue, still having this.
@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