Flutter background_location 在初始化时崩溃

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

在 iOS 设备上,我成功请求权限,但是当调用 startLocation 服务时,应用程序只是退出

BackgroundLocation.startLocationService();

在调试模式下运行,我可以看到这个错误

*** -[CLLocationManager setAllowsBackgroundLocationUpdates:] 中断言失败,CLLocationManager.m:972 *** 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无效参数不满足:!stayUp ||” CLClientIsBackgroundable(内部->fClient) || _CFMZEnabled()' *** 首先抛出调用堆栈: (0x1808ffc60 0x19812fee4 0x1820a4c80 0x1878541b0 0x102190f54 0x1021912c0 0x102190a98 0x102190b30 0x1056ba8b8 0x10513c58c 0x180 5bf094 0x1805c0094 0x18056cd44 0x18056c994 0x1808bb014 0x1808784f8 0x18088b174 0x1a13ca988 0x18308da88 0x182e26f78 0x197217ee4 0x 1020485c8 0x102048540 0x102048644 0x10226c4d0) libc++abi:以 NSException 类型的未捕获异常终止

  • 线程 #1,队列 = 'com.apple.main-thread',停止原因 = 信号 SIGABRT 帧#0:0x00000001bb1e3bbc libsystem_kernel.dylib`__pthread_kill + 8

我不确定这意味着什么或如何处理。

flutter
1个回答
0
投票

作为苹果官方文档

重要

如果您的 iOS 应用程序使用在使用应用程序时访问用户位置信息的 API,则需要此密钥。

如果您想使用定位服务,您需要将其添加到您的

ios/Runner/info.plist

<key>NSLocationWhenInUseUsageDescription</key>
<string>any text you want</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>any text you want</string>
© www.soinside.com 2019 - 2024. All rights reserved.