zoontek / react-native-permissions

An unified permissions API for React Native on iOS, Android and Windows.
MIT License
4.1k stars 836 forks source link

ios请求麦克风权限返回不可用unavailable #886

Closed yuanjunbao closed 3 months ago

yuanjunbao commented 4 months ago

Before submitting a new issue

Bug summary

通过react-native-permissions获取ios麦克风权限返回unavailable,但是我的设备是支持的,我通过ios原生模块独立封装了一个获取麦克风权限的API来解决这个问题的,我建议你们可以兼容一下ios的麦克风权限请求

Library version

@4.1.5

Environment info

info Fetching system and libraries information...
System:
  OS: macOS 14.2.1
  CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Memory: 39.05 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.10.0
    path: /usr/local/bin/node
  Yarn:
    version: 1.22.22
    path: ~/im_app/node_modules/.bin/yarn
  npm:
    version: 10.2.3
    path: /usr/local/bin/npm
  Watchman:
    version: 2024.05.06.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.11005911
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.11
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.7
    wanted: 0.72.7
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Steps to reproduce

Reproducible sample code

const granted = await check(PERMISSIONS.IOS.MICROPHONE);

                if (granted === 'granted') {
                    console.log('You already have the permission');
                    // 这里可以进行录音操作  
                } else {
                    const status = await request(PERMISSIONS.IOS.MICROPHONE);
                    if (status === 'granted') {
                        console.log('Permission Granted');
                        // 用户同意了权限请求,可以进行录音操作  
                    } else {
                        console.log('Permission Denied', status);
                        // 用户拒绝了权限请求  
                    }
                    requestMicrophonePermission() // 封装React-Native原生模块请求ios麦克风权限
                }