将应用程序保持在后台模式以连续更新位置 [英] Keeping the app in background mode for continuos location updates

查看:162
本文介绍了将应用程序保持在后台模式以连续更新位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目正在使用CLLocationManager对象,它通过以下方式接收更新: locationManager:didUpdateToLocations:

My project is using a CLLocationManager object, receiving updates via: locationManager:didUpdateToLocations:

即使我的应用程序在后台,我仍要这些更新.因此,在info.plist中,我已将必需的后台模式"列表设置为App寄存器以进行位置更新.

I want these updates even though my app is in the background. So in info.plist i have set the, "Required background modes" list to App registers for location updates.

但是我的测试表明它没有在后台状态下收到更新.

But my testing shows that it does not receive the updates in background state.

但是,我不确定我对背景状态/暂停状态的正确理解. 我是这样认为的:

However, i'm not sure i'm having the correct perception of background state/ suspended state. This is how i think it works:

After the home button is pressed, the app enters background mode for 5 seconds, 
and then enter suspended state.

我想这就是为什么它不起作用的原因.但是,如果将info.plist设置为用于位置更新的应用程序注册"并不能阻止应用程序进入暂停状态,那我该如何实现呢?

I guess this is why it's not working. But if setting the info.plist to ""app registers for location updates" does not keep the app from reaching suspended state, then how do i achieve it?

按主页"按钮和按锁定"按钮有什么区别(如果有)?我说的是国家.

What is the difference (if any) in pressing the Home button and pressing the lock button? State-wise i mean.

我已经阅读了本指南的相关部分: http://www.raywenderlich. com/29948/backgrounding-for-ios

I have read the relevant parts of this guide: http://www.raywenderlich.com/29948/backgrounding-for-ios

我还是IOS的新手,所以我可能忽略了一些东西.

Im still new to IOS, so i might have overlooked something.

推荐答案

首先,您是否在您检查了backgroundRefreshStatus吗?是否可以根据此应用在后台运行该应用?

Have you checked backgroundRefreshStatus? Is this app allowed to run in the background according to it?

pausesLocationUpdatesAutomatically的值是什么?

您要求什么精度?您是否在采取足够的行动以产生超过该精度的变化?

What accuracy are you requesting? Are you moving sufficiently to generate changes over that accuracy?

您打电话给startUpdatingLocation吗?

这是iOS 6还是7?如果是iOS 7,请务必观看课程204:多任务处理的新功能?"发生了一些变化,iOS现在比以前更积极地关闭应用程序.

Is this iOS 6 or 7? If iOS 7, make sure to watch Session 204: "What’s New with Multitasking?" There have been several changes and iOS is now more aggressive about shutting down apps than it was previously.

这篇关于将应用程序保持在后台模式以连续更新位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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