iOS 中的背景 GPS.这可能吗? [英] Background GPS in iOS. Is this possible?

查看:22
本文介绍了iOS 中的背景 GPS.这可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以通过未运行或至少在后台运行的应用程序获取 iPhone 的位置.我想要做的是让 iPhone 在到达某个坐标时发送推送通知.这可能吗?如果是这样,有人能把我引向正确的方向吗?

I was wondering if it was possible to get the location of the iPhone with an app that isnt running, or at least running in the background. What I want to do is have the iPhone send a push notification when it arrives at a certain coordinate. Is this possible? If so, could someone put me in the right direction?

谢谢,本

推荐答案

是的,有可能.您的应用程序可以要求收到重大位置变化的通知,或者在后台执行时继续使用 GPS.前者——Apple 推荐的方法——以牺牲准确性为代价使用更少的功率 (this 博客文章表明更新精确到大约 500m),而后者是设备可以管理的准确度.这在 iOS 应用程序编程指南和和 位置感知编程指南.

Yes, it is possible. Your application can ask to be notified of significant location changes or to simply continue using the GPS while executing in the background. The former—the approach recommended by Apple—uses less power at the cost of accuracy (this blog post indicates that the updates are accurate to roughly 500m), while the latter is as accurate as the device can manage. This is all detailed in the iOS Application Programming Guide and and the Location Awareness Programming Guide.

如果您只是希望在设备移动到特定区域时通知您的应用程序,您可能需要查看 CLLocationManagerstartMonitoringForRegion:desiredAccuracy:.如果设备移动到特定地理区域,您的应用就会启动(即使它没有运行!).

If you simply want your application to be notified when the device moves into a particular region, you may want to look into CLLocationManager's startMonitoringForRegion:desiredAccuracy:. If the device moves into a particular geographical region, your app is launched (even if it's not running!).

这篇关于iOS 中的背景 GPS.这可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆