在iOS 10中多次调用applicationDidBecomeActive

时间:2016-10-03 11:39:53

标签: ios core-location

在我的应用用户位置允许权限弹出窗口在应用程序启动时闪烁多次。

我的代码

AppDelegate.m 

- (void)applicationDidBecomeActive:(UIApplication *)application
{
   [self.shareModel startMonitoringLocation];
}

LocationManager.m

- (void)startMonitoringLocation {
     if (_anotherLocationManager)
        [_anotherLocationManager stopMonitoringSignificantLocationChanges];

    self.anotherLocationManager = [[CLLocationManager alloc]init];
    _anotherLocationManager.delegate = self;
    _anotherLocationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
  _anotherLocationManager.activityType = CLActivityTypeOtherNavigation;
    _anotherLocationManager.allowsBackgroundLocationUpdates=YES;
    if(IS_OS_8_OR_LATER) {
        [_anotherLocationManager requestAlwaysAuthorization];
    }
    [_anotherLocationManager startMonitoringSignificantLocationChanges];
}

在我的代码中,applicationDidBecomeActive被多次调用,因此locationmanager在应用程序启动时多次弹出,因为我的应用程序在最近的更新中被拒绝

Rejection issue:

From Apple
2. 1 PERFORMANCE: APP COMPLETENESS
Performance - 2.1


We discovered one or more bugs in your app when reviewed on iPad and iPhone running iOS 10.0.2 on Wi-Fi connected to an IPv6 network.

Specifically, your app’s Background Location modal alert continuously appears and prevents access to the app.

Next Steps

Please run your app on a device while connected to an IPv6 network (all apps must support IPv6) to identify the issue(s), then revise and resubmit your app for review.

我已经研究了几天但是在iOS10中找不到问题。

任何想法/建议都非常有用&非常感谢

1 个答案:

答案 0 :(得分:0)

为什么不添加

    [self.shareModel startMonitoringLocation];

in

applicationDidFinishLaunchingWithOptions:

或尝试:

- (void)startMonitoringLocation {
 if (_anotherLocationManager == nil) {
self.anotherLocationManager = [[CLLocationManager alloc]init];
_anotherLocationManager.delegate = self;
_anotherLocationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
_anotherLocationManager.activityType = CLActivityTypeOtherNavigation;
_anotherLocationManager.allowsBackgroundLocationUpdates=YES;

if(IS_OS_8_OR_LATER) {
    [_anotherLocationManager requestAlwaysAuthorization];
}
[_anotherLocationManager startMonitoringSignificantLocationChanges];
} else {
    [_anotherLocationManager stopMonitoringSignificantLocationChanges];
}
}