【问题标题】:My app was rejected from apple using location services in background我的应用在后台使用定位服务被苹果拒绝
【发布时间】:2015-05-02 18:15:12
【问题描述】:

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

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 文件中,我将“应用程序注册以进行位置更新”作为“必需的后台模式”。但是苹果拒绝了我的申请,并说如果你在后台使用位置,你必须使用实时位置更新。

如果我想在背景中使用具有距离过滤器的位置,请告诉我需要使用什么。

【问题讨论】:

    标签: ios gps xcode6


    【解决方案1】:

    如果您想在没有“应用程序注册位置更新”后台模式的情况下进行后台更新,您必须使用startMonitoringSignificantLocationChanges。它应该每隔几公里在后台生成位置更新。 没有其他方法可以在后台获取位置更新(没有后台模式)。

    Apple documentation

    startMonitoringSignificantLocationChanges 不依赖过滤器:

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

    编辑:

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

    CoreMotion updates in background state

    【讨论】:

    • 感谢您的回复。我在 iPhone5s 设备下方使用运动传感器计算步数,所以我需要在后台激活我的应用程序。有没有其他方法可以做到这一点。
    • 是的,有一些技巧,比如在后台运行音乐。但结果与位置更新相同:您仍然需要启用后台模式 => 它可能会被苹果拒绝。
    • 我在 iPhone5s 及更高版本上使用 M7 芯片,但在 4、4s、5 和 5c 上呢
    • 如果您想询问 m7 和核心运动,您必须创建另一个问题。这是题外话。如果我回答了您的原始问题,请将我的问题标记为正确。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-09
    • 2016-08-08
    • 1970-01-01
    • 1970-01-01
    • 2017-07-01
    • 2014-11-19
    相关资源
    最近更新 更多