requestRecordPermission 在 ios10 xcode 8 beta 3 中不起作用

requestRecordPermission not working in ios10 xcode 8 beta 3

当我尝试请求使用麦克风录音的权限时,它抛出 " [access] "

AVAudioSession.sharedInstance().requestRecordPermission({(granted: Bool)-> Void in
        if granted {

            print("yass")
        } else {
            print("Permission to record not granted")
        }
    })

有人有解决方法吗? 这适用于 7.3

如果输出日志是这样的:

2016-07-08 16:41:11.268943 project-name[362:56625] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2016-07-08 16:41:11.272276 project-name[362:56625] [MC] Reading from public effective user settings.
2016-07-08 16:41:11.356590 project-name[362:56700] [access] <private>

您可能缺少相机使用权限。

解决方案是将 "Privacy - Camera Usage Description" 密钥添加到您的 Info.plist。

Here's a link to an Apple Developer Forum discussion explaining why this occurs.