2016-10-03 42 views
1

在我的應用程序中,用戶位置允許彈出窗口多次在應用程序啓動時閃爍。iOS中的多次調用applicationDidBecomeActive 10

我的代碼

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的問題。

任何意見/建議將是非常有益的&非常感謝

+2

您的應用程序將成爲任何時候系統對話框(如權限對話框)都顯示爲非活動狀態,並且一旦該對話框被解除,該對話框變爲活動狀態,因此您可能應該使用didEnterForeground – Paulw11

+0

@ Paulw11正如您所說的,每當權限對話框被解除時都會調用applicationDidBecomeActive。但是我們沒有在iOS中使用didEnterForeground,並且在權限對話被解除時不調用applicationWillEnterForeground。可以讓我知道如何進一步 – Honey

+0

爲什麼你想知道權限對話框已被解除?如果您在用戶對位置權限請求做出響應後嘗試執行某些操作,則應該使用'didChangeAuthorization'位置管理器委託方法 – Paulw11

回答

0

爲什麼不

applicationDidFinishLaunchingWithOptions: 

添加

[self.shareModel startMonitoringLocation]; 

或嘗試:

- (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]; 
} 
} 
相關問題