后台模式下的 iOS 区域监控
我在我的应用程序中使用区域监控,但遇到了一个问题,但找不到任何答案。区域监控在后台模式下如何工作?
根据位置感知 PG 的说法:
每次用户的当前位置 跨越边界区域,系统 生成适当的区域事件 为您的应用程序。如果你的 应用程序已经在运行,这些 活动直接发送至代表 任何当前位置管理器对象。 如果您的应用程序没有运行, 系统将其启动于 背景以便它可以响应。
现在,这个问题是:我的应用程序处于挂起模式,已输入一个区域并且应该传递触发器,此事件是否将“直接”发送到委托的:
locationManager:didEnterRegion:
?如果应用程序处于后台模式,同样的问题。换句话说,我应该考虑在挂起和后台模式下使用任何代码来接收此事件吗?或者iOS将首先启动应用程序,然后直接将事件发送给委托而不需要任何BG代码?
I am using Region Monitoring in my app and I faced a question that I couldn't find any answer to it. How does region monitoring work in background mode?
According to Location Awareness PG:
Every time the user’s current location
crosses a boundary region, the system
generates an appropriate region event
for your application. If your
application is already running, these
events go directly to the delegates of
any current location manager objects.
If your application is not running,
the system launches it in the
background so that it can respond.
Now, this question is: my app is in the suspended mode, a region has been entered and a trigger should be delivered, does this event will be send "directly" to the delegate's:
locationManager:didEnterRegion:
?? Same question if the app is in background mode. In other words, is there any code I should consider in suspend and background mode to receive this event? or the iOS will first launch the application, then send the event to the delegate directly without any need to BG code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
区域监控 如果您处于后台,则当您进入受监控区域时重新启动您的应用程序。
但是,在应用程序重新启动后,您必须再次配置位置管理器。
像这样的东西-
Region monitoring Relaunches your application when you enter the monitored region if you are in background .
however you have to again configure your location manager after the app relaunches .
something like this -
据我所知,区域监控仅适用于iPhone4,并且它基于改变通信塔的设备。这样,它使用的电池比标准后台位置更新要少得多。
确保您启用了适当的背景模式。只要您实现了该委托,您就应该准备就绪。
As far as I know region monitoring only works with iPhone4 and it's based on the device changing the communication towers. This way it uses way less battery than the standard background location update.
Make sure you enabled the appropriate background modes. As long as you implement that delegate, you should be ready to go.
启用背景模式
启用位置更新和后台获取
enable Background Modes
in that enable Location updates and Background Fetch