gpt4 book ai didi

ios - Swift 区域监控本地通知触发器

转载 作者:行者123 更新时间:2023-11-28 08:17:23 27 4
gpt4 key购买 nike

我正在开发一个应用程序来在进入某个区域时触发本地通知。但是,有时当手机被锁定时,即使我已经在该地区待了一段时间,通知也没有弹出。只有按下电源/主页按钮时才会显示通知弹出窗口(手机仍处于锁定模式)。

一般来说,一切似乎都正常,除了有时只有在按下电源/主页按钮唤醒手机时才会显示通知,尽管它仍然处于锁定状态。

希望有人能赐教! =)

最佳答案

根据开发商documentation .在核心位置框架中,有两个服务可以为您提供当前位置信息。

  1. The standard location service is a configurable, general-purpose solution for getting location data and tracking location changes for the specified level of accuracy.

  2. The significant-change location service delivers updates only when there has been a significant change in the device’s location, such as 500 meters or more.

您需要使用标准定位服务来在后台监控位置

If your iOS app must keep monitoring location even while it’s in the background, use the standard location service and specify the location value of the UIBackgroundModes key to continue running in the background and receiving location updates. (In this situation, you should also make sure the location manager’s pausesLocationUpdatesAutomatically property is set to YES to help conserve power.)

关于ios - Swift 区域监控本地通知触发器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42241028/

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