应用程序在后台运行时如何获取当前位置
我想得到参考,当我们的应用程序在后台运行时,我们如何找到当前的纬度和经度。
如果您有任何建议,请建议我...
提前致谢。
I want to get reference that, How can we find out current Latitude and Longitude when our application is running in background..
If you have any suggestion then please suggest me...
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您需要告诉 iOS 您的应用程序将在后台运行以检索用户位置。
通过将
所需的背景模式
添加到info.plist并将一项设置为应用程序注册位置更新
来完成此操作,刚刚设置了
CLLocationManager
开始监视位置变化。Apple 建议您的应用仅使用
重大更改
来节省电池:http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html#//apple_ref/doc/uid/TP40007072-CH5-SW6Well first you need to tell iOS that your app will run in background with for retrieving the user location.
Do this by adding the
Required background modes
to the info.plist and set one item toApp registers for location updates
The just set up the
CLLocationManager
to start monitoring location changes.Apple does suggest that your app only use
significant changes
to save battery: http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html#//apple_ref/doc/uid/TP40007072-CH5-SW6