gpt4 book ai didi

ios - 如何处理“设置”应用中位置权限的更改

转载 作者:行者123 更新时间:2023-11-29 01:20:28 26 4
gpt4 key购买 nike

我正在尝试弄清楚如何正确处理位置权限的更改。到目前为止,我使用委托(delegate)方法处理更改:locationManager:didChangeAuthorizationStatus:。但我只能确定这在应用程序在前台运行时有效。

如果用户在“设置”应用中更改位置权限,会发生什么情况。如果应用程序未运行,则应用程序将在应用程序启动时看到更改,所以没关系。但是,如果应用程序被挂起,应用程序如何收到通知?委托(delegate)方法 locationManager:didChangeAuthorizationStatus: 是否仍然在某一时刻被调用?

最佳答案

The app is in the background but is not executing code. The system moves apps to this state automatically and does not notify them before doing so. While suspended, an app remains in memory but does not execute any code. When a low-memory condition occurs, the system may purge suspended apps without notice to make more space for the foreground app.

所以你的问题有点微妙。虽然应用程序特别处于挂起状态,但它不运行任何代码。 但是,当位置状态发生变化时(假设您的应用已调用 requestAlwaysAuthorization 并且用户已授予访问权限),应用将被“唤醒”并重新置于后台状态。来自 the iOS Developer Library

If you leave the significant-change location service running and your iOS app is subsequently suspended or terminated, the service automatically wakes up your app when new location data arrives. At wake-up time, the app is put into the background and you are given a small amount of time (around 10 seconds) to manually restart location services and process the location data. (You must manually restart location services in the background before any pending location updates can be delivered.

因此,为了回答您的问题,该应用程序不会在暂停状态下接收位置更新;然而,它被置于后台状态,最终接收到位置更新。

关于ios - 如何处理“设置”应用中位置权限的更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34667149/

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