我需要使用Xamarin.Essentials在 Xamarin.iOS 应用程序中请求权限。到目前为止,我发现的所有示例都是关于我没有使用的 Xamarin.Forms。
到目前为止,我发现的所有示例都是关于在按下按钮时询问权限,这对于实验来说很好,但对于生产应用程序却无用。
我有以下异步代码:
// TODO Move the permission requests to a more appropriate location?
var status = await Permissions.CheckStatusAsync<Permissions.Camera>();
if (status != PermissionStatus.Granted)
{
status = await Permissions.RequestAsync<Permissions.Camera>();
}
status = await Permissions.CheckStatusAsync<Permissions.Microphone>();
{
status = await Permissions.RequestAsync<Permissions.Microphone>();
}
我从 ViewDidLoad 异步覆盖中调用它。每当我调用 Permissions.RequestAsync() 时,应用程序就会崩溃并显示以下输出
2020-05-08 10:21:05.815 yaka[714:200964] error: * Assertion at /Users/builder/jenkins/workspace/archive-mono/2020-02/ios/release/mono/mini/debugger-agent.c:4568, condition `array->len == 1' not met
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x1014e7754: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x101065470: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x10123472c: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x101064370: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x1014ab360: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x1015ac108: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x1015592a0: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x101559224: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x10105f0c0: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x1014ab360: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x1014e7754: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x101065470: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x10123472c: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x101064370: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x1014ab360: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x1015ac108: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x1015592a0: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x101559224: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x10105f0c0: 8
[PLCrashReport] plframe_cursor_read_dwarf_unwind_int:131: Failed to find FDE the current frame pc: 0x1014ab360: 8
我的 info.plist 包含以下有关权限的内容:
<key>NSCameraUsageDescription</key>
<string>L'accès est réservé au vidéoconférences.</string>
<key>NSMicrophoneUsageDescription</key>
<string>L'accès est réservé au vidéoconférences.</string>
必须有适当的位置才能安全地调用此编码,但我无法弄清楚。
任何帮助表示赞赏。