0

我毫不懷疑,想知道是否有必要重新分配所有地區的位置經理,如果它收到appEnterInBackGround的通知?地區監測和背景

這是一些代碼片段。

# pragma mark - BackGround Notification 
    -(void)applicationEnterBackground 
    { 
     monitorLocationManager = [selectRouteController sharedLocationMonitor]; 
     monitorLocationManager.delegate = self; 
     for (Geofencing *gObjects in plotingArrays) { 
     CLCircularRegion *getRegion = [self dictToRegion:gObjects]; 
     [monitorLocationManager startMonitoringForRegion:getRegion]; 
    } 
    } 

那麼,是否需要再次重新分配區域位置馬槽當應用程序在後臺輸入:

- (IBAction)startAction:(id)sender 
{ 
    for (Geofencing *gObjects in plotingArrays) { 
     CLCircularRegion *getRegion = [self dictToRegion:gObjects]; 
     [monitorLocationManager startMonitoringForRegion:getRegion]; 
    } 
    } 

所以,當應用程序在回地面,我沒有這樣的進入?

+ (CLLocationManager *)sharedLocationMonitor { 
static CLLocationManager *locationMonitor; 
static dispatch_once_t onceToken; 
dispatch_once(&onceToken, ^{ 

     locationMonitor = [[CLLocationManager alloc] init]; 
     locationMonitor.desiredAccuracy = 
     kCLLocationAccuracyBestForNavigation; 

     locationMonitor.activityType = 
     CLActivityTypeAutomotiveNavigation; 
     [locationMonitor requestAlwaysAuthorization]; 

     if(IS_OS_9_OR_LATER){ 
      locationMonitor.allowsBackgroundLocationUpdates = YES; 
     } 

     if(SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(@"8.4")){ 
      locationMonitor.pausesLocationUpdatesAutomatically = NO; 
     } 
    }); 
    return locationMonitor; 
    } 

PLIST:

App plist configuration

回答

0

不,你並不需要重新啓動監測或一旦該區域被分配到位置上的經理行動startAction:

UPDATE1它會自動監測適用於您的應用在後臺進入時的區域。它會自動監控區域,如果你已經配置它。

您需要配置在info.plist中以下內容:

<key>NSLocationAlwaysUsageDescription</key> 
<string>I want to get your location Information in background</string> 

<key>UIBackgroundModes</key> 
<array> 
    <string>location</string> 
</array> 

而且你還需要AllowsBackgroundLocationUpdates設置爲yes。

[monitorLocationManager setAllowsBackgroundLocationUpdates:YES]; 
+0

hy。你能幫我交叉檢查代碼嗎?請參閱UPDATE1 – Ketan

+0

附加的PLIST屏幕截圖。 – Ketan