简体   繁体   English

Swift Region Monitoring本地通知触发器

[英]Swift Region Monitoring Local Notification trigger

I'm doing an app to trigger a local notification when a region is entered. 我正在做一个应用程序,以便在输入区域时触发本地通知。 However, sometimes when the phone is locked, the notifications didn't pop up even I've been in the region area for a while. 但是,有时当手机被锁定时,即使我已经在区域内停留了一段时间,通知也没有弹出。 The notification popup will show only when the power/home button is pressed(phone still in locked mode). 通知弹出窗口仅在按下电源/主页按钮时显示(手机仍处于锁定模式)。

In general, all seems to be working except that sometimes the notification will show only when power/home button is pressed to awake the phone although it is still locked. 一般情况下,所有似乎都在工作,但有时通知仅在按下电源/主页按钮以唤醒手机时才会显示,尽管它仍处于锁定状态。

Hope someone can enlighten me please! 希望有人能赐教我! =) =)

According to the developer documentation . 根据开发人员文档 In core-location framework, two services can give you the current location information. 在核心位置框架中,两个服务可以为您提供当前位置信息。

  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. 重要更改位置服务仅在设备位置发生重大变化(例如500米或更长)时才会提供更新。

You need to use standard location services to keep monitoring location in background 您需要使用标准位置服务来保持后台监控位置

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. 如果您的iOS应用程序必须保持监视位置,即使它在后台,请使用标准位置服务并指定UIBackgroundModes键的位置值以继续在后台运行并接收位置更新。 (In this situation, you should also make sure the location manager's pausesLocationUpdatesAutomatically property is set to YES to help conserve power.) (在这种情况下,您还应确保位置管理器的pausesLocationUpdatesAutomatically属性设置为YES以帮助节省电量。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM