“未检测到权限处理程序。” 在 Expo 和 dev-client 构建中使用 React-native-permissions 时出错

Mic*_*ael 6 javascript react-native expo react-native-permissions expo-eas

我正在尝试让react-native-permissions我的 Expo 开发客户端版本运行。构建成功,但是当我启动应用程序时,我得到一个相对通用的“未检测到权限处理程序”。错误。

研究建议添加权限ios/Podfile并确保ios/<appname>/Info.plist条目需要存在。

该应用程序无需react-native-permissions即可运行,但我想使用该包来检查是否设置了权限并引导用户进行设置(如果没有)。

ios/Podfile

  pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone"
  pod 'Permission-SpeechRecognition', :path => "#{permissions_path}/SpeechRecognition"
Run Code Online (Sandbox Code Playgroud)

ios/<appname>/Info.plist(相关条目)

    <key>NSMicrophoneUsageDescription</key>
    <string>CUSTOM: Allow to access the microphone</string>
    <key>NSSpeechRecognitionUsageDescription</key>
    <string>CUSTOM: Allow to securely recognize user speech</string>
Run Code Online (Sandbox Code Playgroud)

app.config.js(博览会)

...
   "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"
                }
            ]
        ]
Run Code Online (Sandbox Code Playgroud)

工作流程

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

Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

小智 -2

我也有同样的问题。然后我阅读了您分享的错误消息,其中包含问题的解决方案。以下步骤对我有用:

  • 检查您的 Podfile 中是否至少链接了一个权限处理程序
  • 卸载此应用程序,删除 xcode DerivedData 文件夹并重建它。

我不需要做第三步。