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.
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
NSLocationWhenInUseUsageDescription tag to Info.plistPermission-LocationWhenInUse podspec to Podfile pod installcheck(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE)unavailable for some reasonDescribe what you expected to happen:
denied at first so I can call request after that!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?
width="400px" />
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
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"
``
2) Clean cachepod cache clean --all
3) Clean build folderXCode -> Product -> Clean build folder
4) Runpod install`
It should help
Most helpful comment
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"
``
2) Clean cachepod cache clean --all3) Clean build folderXCode -> Product -> Clean build folder4) Runpod install`It should help