【问题标题】:applicationDidBecomeActive called multiple times in iOS 10在 iOS 10 中多次调用 applicationDidBecomeActive
【发布时间】:2016-10-03 11:39:53
【问题描述】:

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

我的代码

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 中找不到问题。

任何想法/建议都会非常有帮助并且非常感谢

【问题讨论】:

  • 您的应用程序将在任何时候显示系统对话框(例如权限对话框)时变为非活动状态,并在该对话框关闭后变为活动状态,因此也许您应该使用 didEnterForeground
  • @Paulw11 正如您所说,每次权限对话框被关闭时都会调用 applicationDidBecomeActive 。但是我们在 iOS 中没有 didEnterForeground 并且当权限对话框被解除时不会调用 applicationWillEnterForeground。你能告诉我如何继续
  • 为什么要知道权限对话框已被解除?如果您在用户响应位置权限请求后尝试执行某些操作,则应使用didChangeAuthorization 位置管理器委托方法
  • @Paulw11 我不想知道权限对话框是否已被解除。只是在对话框被解除后每次调用 applicationDidBecomeActive 然后再次执行 locationmanager.m 代码,这将持续大约 5-6 次,位置弹出窗口继续闪烁,不允许我点击“允许”或“不允许”按钮
  • 我想了解的是,您为什么在didBecomeActive 中调用startMonitoringLocation

标签: ios core-location


【解决方案1】:

为什么不添加

    [self.shareModel startMonitoringLocation];

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];
}
}

【讨论】:

    猜你喜欢
    • 2012-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-11
    • 2011-04-21
    • 2014-11-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多