2016-08-23 1 views
1

significantChange로 장치 위치를 모니터링하고 모든 것이 잘 작동하고 모든 변경 사항이 웹 서비스에서 업데이트됩니다.significantChange가 활성화 된 위치 사용 중지

사용자가 시스템 위치를 끄면 어떻게됩니까? 한 번 더 호출 된 significantChange, 그래서 그 사용자가 위치를 사용하지 않도록 설정할 수 있습니까?

+0

https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManagerDelegate_Protocol/index.html#//apple_ref/occ/intfm/CLLocationManagerDelegate/locationManager:didChangeAuthorizationStatus : – Paulw11

+0

수 있지만 AuthorizationChanges 이벤트가 내 앱을 다시 시작합니까? –

+0

앱이 강제 종료되면 어쨌든 위치 정보가 업데이트되지 않습니다. 앱이 메모리 부족으로 인해 일시 중지되었거나 종료 된 경우에도이 위임 메서드를 호출해야합니다. 그것을 시도하는 것은 꽤 쉽습니다. 위치가 비활성화되면 위치 업데이트를받지 못할 것이라고 말할 수 있습니다. – Paulw11

답변

0

위치 서비스 상태를 확인하려면 viewDidlaod()에 다음과 같이하십시오.

override func viewDidLoad() { 
    if CLLocationManager.locationServicesEnabled() { 
    switch(CLLocationManager.authorizationStatus()) { 
    case .NotDetermined, .Restricted, .Denied: 
     print("No access") 
    case .AuthorizedAlways, .AuthorizedWhenInUse: 
     print("Access") 
    } 
    } else { 
    print("Last know location: \(location)" // retrieve this from the location you saved it. 
    // You could also then set some value on your sever to show that it has been turned off. 
    print("Location services are not enabled") 
    } 
    } 
} 

그런 다음 didUpdateLocations 마지막 위치를 저장하십시오.

func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { 
    let location = locations.last // save this in defaults or some way to revive at a later time. 
} 
관련 문제