我的应用程序在后台使用位置服务被苹果拒绝

时间:2015-03-02 11:47:01

标签: ios gps xcode6

我正在使用以下代码进行定位 -

self.locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    locationManager.desiredAccuracy=500;
    locationManager.distanceFilter=kCLLocationAccuracyKilometer;


#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000

    if ([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
    {
        [locationManager requestAlwaysAuthorization];
    }
#else


#endif

    [locationManager startUpdatingLocation];

    //Disable auto location pause in background
    if ([self.locationManager respondsToSelector:@selector(pausesLocationUpdatesAutomatically)])
    {
        self.locationManager.pausesLocationUpdatesAutomatically = NO;
    }

在我的plist文件中,我使用“App registers for location updates”作为“Required background modes”。但苹果拒绝了我的申请,并表示如果你在后台使用位置,你必须使用实时位置更新。

如果我想在带有distancefilter的背景中使用位置,请告诉我需要使用的内容。

1 个答案:

答案 0 :(得分:0)

如果您希望在没有"应用程序寄存器进行位置更新的情况下进行后台更新"您必须使用startMonitoringSignificantLocationChanges的后台模式。它应该每隔几公里在背景中生成位置更新。 没有别的办法在后台获取位置更新(没有后台模式)。

Apple documentation

startMonitoringSignificantLocationChanges并不依赖于过滤器:

  

它不依赖distanceFilter属性中的值来生成事件。

修改

正如我在评论中提到的,您可以像RunKeeper应用程序一样使用背景音频。它仍然是一个灰色区域,意味着你的应用程序很可能仍被拒绝

CoreMotion updates in background state