"No permission handler detected." error using react-native-permissions with Expo and dev-client build

6.6k Views Asked by At

I am trying to get react-native-permissions in my dev-client build of Expo to run. The build succeeds, but when I start the app, I am getting a relatively generic "No permission handler detected." error.

Research suggest that adding permissions to the ios/Podfile and making sure that ios/<appname>/Info.plist entries need to exist.

The app works without react-native-permissions, but I want to use the package to check if permissions are set and direct the user towards settings, if not.

ios/Podfile

  pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone"
  pod 'Permission-SpeechRecognition', :path => "#{permissions_path}/SpeechRecognition"

ios/< appname >/Info.plist (relevant entries)

    <key>NSMicrophoneUsageDescription</key>
    <string>CUSTOM: Allow to access the microphone</string>
    <key>NSSpeechRecognitionUsageDescription</key>
    <string>CUSTOM: Allow to securely recognize user speech</string>

app.config.js (expo)

...
   "plugins": [
            "@react-native-firebase/app",
            "@react-native-firebase/perf",
            "@react-native-firebase/crashlytics",
            "@react-native-google-signin/google-signin",
            ["react-native-fbsdk-next",
                {
                    "appID": "xxx",
                    "clientToken": "xxx",
                    "displayName": "xxx",
                    "advertiserIDCollectionEnabled": false,
                    "autoLogAppEventsEnabled": false,
                    "isAutoInitEnabled": true
                }
            ],
            [
                "@react-native-voice/voice",
                {
                    "microphonePermission": "CUSTOM: Allow access the microphone",
                    "speechRecognitionPermission": "CUSTOM: to securely recognize user speech"
                }
            ]
        ]

Workflow

expo prebuild --clean

cd ios

# modify `Podfile` and add below two lines
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone"
pod 'Permission-SpeechRecognition', :path => "#{permissions_path}/SpeechRecognition"

pod install

cd ..
eas build --platform ios --profile development --local

enter image description here

3

There are 3 best solutions below

0
On

I was also having the same issue. Then I read the error message that you shared contained the solution to the problem. The following steps worked for me:

  • Check that you link at least one permission handler in your Podfile
  • Uninstall this app, delete your xcode DerivedData folder and rebuild it.

I did't need to do the third step.

1
On

I have been having the same issue for 2 days now. Turns out that react-native-permissions do not really work well with expo managed projects.

I don't know what I was doing before but since my project required just medialibrary permissions for now, the best and only alternative that worked for me was expo-media-library.

Steps that I did to make it work include:

  • removing react-native-permissions: You can do so with yarn remove react-native-permissions
  • installing expo-media-library with npx expo install expo-media-library
  • cd ios then install pods again with pod install. After do not forget to cd ..
  • uninstall your app from your simulator.
  • remove DerivedData from xcode: find derived data usually in /Users/[yourUsername]/Library/Developer/xcode/DerivedData. You can delete with rm -r command on your terminal
  • rebuild your ios app with npx expo run:ios

Please note that this worked for my expo managed project with some react-native modules such as react-native-image-picker, however, this should not be the only solution and I will research other alternatives to this and find better solutions.

If you still face some issues after rebuilding, create a new eas build with eas build --profile development --platform ios. For react-native-image-picker some issues I had were solved here: issues with react-native-image-picker

0
On

react-native-permission will only work if you have ejected your expo app and have then ran prebuild for IOS. BUT if you are using EAS as your pipeline to build and create dev builds, you need to use: expo-permissions lib.