iOS模拟器在麦克风权限请求中崩溃

问题描述 投票:0回答:1

我的环境:

  • permission_handler 3.0.0
  • 颤动v1.2.1
  • OSX High Sierra 10.13.6
  • Xcode版本10.1。

当我在iOS模拟器中请求麦克风权限时,我的应用程序崩溃了。

PermissionStatus mic = await PermissionHandler()
    .checkPermissionStatus(PermissionGroup.microphone);
print('microphone permission? ${mic.toString()}');
try {
    if (mic != PermissionStatus.granted) {
        await PermissionHandler().requestPermissions([PermissionGroup.microphone]);
    }
} catch (e) {
    print(e);
}

没有抛出或捕获错误,但在flutter调试控制台中,我看到:

flutter: microphone permission? PermissionStatus.unknown
Lost connection to device.

这意味着checkPermissionStatus()返回unknown。但是当我请求许可时,应用程序崩溃了。我无法在真正的iPhone上尝试这个。一切都在Android模拟器上完美运行。

我已经看到Xcode 10.1中有一些问题与麦克风:

我试过的

  • flutter clean新建
  • 在硬件>音频输入中更改模拟器麦克风输入

我可以尝试升级到Xcode 10.2,但我需要先获得mojave。尽可能避免这种情况,因为它甚至可能无法解决问题。我也可以尝试使用真正的iPhone设备而不是模拟器。但是,我很想让模拟器不会崩溃。

有人能够使用10.1在Xcode 10.2 / permission_handler: 3.0.0模拟器中授予麦克风权限吗?那另一个flutter权限插件怎么样?

ios xcode flutter ios-simulator microphone
1个回答
2
投票

请确保您已将正确的条目添加到Info.plist文件中(对于Flutter项目,此文件位于ios/Runner/文件夹中)。

要访问麦克风,您需要在<dict>标记之间添加以下行:

<key>NSMicrophoneUsageDescription</key>
<string>this application needs access to the microphone</string>

更多信息可以在here.找到

并且可以找到Info.plist的完整示例here.

© www.soinside.com 2019 - 2024. All rights reserved.