如何使用延迟位置iOS 6? [英] How to work with deferred location iOS 6?

查看:150
本文介绍了如何使用延迟位置iOS 6?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用新的iOS 6功能进行自定义更新,但继续收到此错误:

I am trying to use the new iOS 6 feature of deffered location updates but keep on getting this error :


didFinishDeferredUpdatesWithError:Error Domain = kCLErrorDomain Code = 11操作无法完成。(kCLErrorDomain错误11。)

didFinishDeferredUpdatesWithError :Error Domain=kCLErrorDomain Code=11 "The operation couldn’t be completed. (kCLErrorDomain error 11.)"

我使用以下代码:

- (DeviceAPI *) init
    {
     locationManager = [[CLLocationManager alloc] init];
     [locationManager setDelegate:self];
     [locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
     [locationManager startUpdatingLocation];
     [locationManager allowDeferredLocationUpdatesUntilTraveled:(CLLocationDistance)100000     timeout:(NSTimeInterval)100000];

    return self;
 }

回调函数:

- (void)locationManager:    (CLLocationManager *)   manager
                        didFinishDeferredUpdatesWithError:(NSError *)error
{
    NSLog(@"didFinishDeferredUpdatesWithError :%@", [error description]);
}

任何帮助?

推荐答案

根据iOS 6.0 SDK的Apple开发者论坛,仅提供延期位置更新:

According to the Apple Developer Forums for the iOS 6.0 SDK, deferred location updates are only available:


  • 在iPhone 5硬件上

  • 运行iOS 6.0或更高版本

  • 所需精度设置为 kCLLocationAccuracyBest kCLLocationAccuracyBestForNavigation 因为需要 GPS芯片。没有手机数据的iPad没有GPS芯片。

  • 调用startUpdatingLocation方法

  • 等待位置更新以大约每秒1次的速度进入

  • 然后开始推迟更新

  • on iPhone 5 hardware
  • running iOS 6.0 or higher
  • desired accuracy set to kCLLocationAccuracyBest or kCLLocationAccuracyBestForNavigation because this requires a GPS chip. An iPad without cellular data does not have a GPS Chip.
  • call the "startUpdatingLocation" method
  • wait for location updates to come in at approximately 1 per second
  • then begin deferring updates

请参阅: https://devforums.apple.com/message/751974#751974

参见docs: allowDeferredLocationUpdates(untilTraveled:timeout :)

See docs: allowDeferredLocationUpdates(untilTraveled:timeout:)

听起来你需要iPhone 5硬件,等待位置更新以1Hz的速度进入。

So sounds like you need iPhone 5 hardware, and to wait for location updates to come in at 1Hz.

此外,正如另一张海报所提到的,你需要在你的委托中实现 locationManager:didUpdateLocations:方法。 / p>

Additionally, as another poster mentioned, you'd need to implement the locationManager:didUpdateLocations: method in your delegate.


最常见的地方叫[ allowDeferredLocationUpdates ]方法在你的委托的
locationManager(_:didUpdateLocations:)方法中。在处理任何
新位置后,如果您希望推迟未来更新
,请调用此方法,直到满足距离或时间条件。如果新事件到达并且
您的应用程序在后台,则会缓存事件并且适当延迟其
交付。

The most common place to call this [allowDeferredLocationUpdates] method is in your delegate’s locationManager(_:didUpdateLocations:) method. After processing any new locations, call this method if you want to defer future updates until the distance or time criteria are met. If new events arrive and your app is in the background, the events are cached and their delivery is deferred appropriately.

来自 docs 。我在 [] 中添加了注释。

From docs. I've added notes inside [].

这篇关于如何使用延迟位置iOS 6?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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