gpt4 book ai didi

ios - 应用程序将从位置唤醒后,didFinishLaunchingWithOptions 中的 LaunchOptions 为 nil

转载 作者:行者123 更新时间:2023-12-01 16:21:12 31 4
gpt4 key购买 nike

我确实在互联网上搜索过,发现一些人遇到了同样的问题,但还没有人得到任何解决方案...所以我希望这里的任何人都是我正在寻找的 G..

1 - 我确实在后台模式中启用了“位置更新”和“后台获取”。

enter image description here

2 - 我确实在正确的位置调用了 locationManager.startMonitoringSignificantLocationChanges(),我在写入和串入我的 Firebase 数据库的方式中检查了这一点,当应用程序将在终止后被唤醒时。

3 - 我正在检查 launchOptions 中是否有位置键,就像 Apple 在他们的文档中一样,请参阅:

https://developer.apple.com/documentation/uikit/app_and_environment/responding_to_the_launch_of_your_app

enter image description here

那么为什么我的 launchOptions 为零?我不明白为什么会这样......因为应用程序正在被唤醒,所以错误不可能在我的 locationManager 处理上......

我在 stackoverflow 上发现了这个但是我的 launchOptions 是 nil 所以代码没有进入 if... Location update even when app is killed/terminated

请帮忙。

最佳答案

看起来你没有在数据库中保存更改。
添加日志并检查发生了什么。
如果使用密码锁定设备,则可以锁定数据库文件。 SignificantLocationChanges 可能会发生这种情况。我希望它的链接能帮助你 - IOS app unable to access files in background when screen locked with passcode

附言此外,对于 startMonitoringSignificantLocationChanges(),您不需要启用“位置更新”,它需要 startUpdatingLocation()
startMonitoringSignificantLocationChanges needs background location enabled?

更新: https://developer.apple.com/documentation/corelocation/cllocationmanager/1423531-startmonitoringsignificantlocati

If you start this service and your app is subsequently terminated, the system automatically relaunches the app into the background if a new event arrives. In such a case, the options dictionary passed to the application(:willFinishLaunchingWithOptions:) and application(:didFinishLaunchingWithOptions:) methods of your app delegate contains the key location to indicate that your app was launched because of a location event. Upon relaunch, you must still configure a location manager object and call this method to continue receiving location events. When you restart location services, the current event is delivered to your delegate immediately. In addition, the location property of your location manager object is populated with the most recent location object even before you start location services.

location 应该在你的 launchOptions 中,我建议只在控制台中打印 launchOption。并通过(可从 XCode -> Devices -> {your device} 查看)查看它,存在哪些键?

关于ios - 应用程序将从位置唤醒后,didFinishLaunchingWithOptions 中的 LaunchOptions 为 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59591130/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com