位置更新自动暂停iOS [英] location update auto pause iOS

查看:381
本文介绍了位置更新自动暂停iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用phonegap建立一个iOS应用程式。我试图让iOS更新其当前位置到我的应用程序,当应用程序在后台运行。我注册了位置更新背景模式,但它不可靠。经过一番研究,我相信iOS会自动暂停位置更新。在CLLocationManager中有一个名为pausesLocationUpdatesAutomatically的属性,我认为它负责此行为。



以下声明来自CoreLocation.framework中的CLLocationManager.h

  / * 
* pausesLocationUpdates自动
*
*讨论:
*指定位置更新可自动可能时暂停。
*默认情况下,对于与iOS 6.0或更高版本链接的应用程序,此值为YES。
* /
@property(assign,nonatomic)BOOL pausesLocationUpdatesAutomatically __OSX_AVAILABLE_STARTING(__ MAC_NA,__ IPHONE_6_0);

有关如何停用此功能的任何观点吗?



非常感谢。



您应该设置

解决方案这个属性为NO,像这样:

  _locationManager.pausesLocationUpdatesAutomatically = NO; 


I'm building an iOS app using phonegap. I'm trying to get iOS to update its current position to my app when the app runs in the background. I've registered the location updates background mode however it's not reliable. After some research, I believe that iOS is automatically pausing the location updates. There's an attribute in CLLocationManager called 'pausesLocationUpdatesAutomatically' that I think is responsible for this behavior.

The following declaration is from CLLocationManager.h in CoreLocation.framework

/*
* pausesLocationUpdatesAutomatically
*
* Discussion:
* Specifies that location updates may automatically be paused when possible.
* By default, this is YES for applications linked against iOS 6.0 or later.
*/
@property(assign, nonatomic) BOOL pausesLocationUpdatesAutomatically __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_6_0);

Any insight on how to disable this feature?

Much appreciated.

Shu

解决方案

You should set this property to NO like this:

_locationManager.pausesLocationUpdatesAutomatically = NO;

这篇关于位置更新自动暂停iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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