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: 행동에 위치 관리자에

갱신 1 할당되면 OR 자동으로 모니터링합니다 앱이 백그라운드에서 입력 될 때 지역 용입니다. 구성한 경우 자동으로 region을 모니터합니다.

은 당신의 Info.plist에 다음을 구성해야합니다

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

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

을 그리고 당신은 또한 yes로 AllowsBackgroundLocationUpdates를 설정해야합니다.

[monitorLocationManager setAllowsBackgroundLocationUpdates:YES]; 
+0

hy. 교차 검사 코드에서 나를 도울 수 있습니까? UPDATE1 – Ketan

+0

첨부 PLIST 스크린 샷도 참조하십시오. – Ketan

관련 문제