1

Possible Duplicate:
Determining if Airplane Mode is enabled on an iPhone?

My application is using the GPS, and I check its availability with :

if([CLLocationManager locationServicesEnabled] && [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized){
    [locationManager startUpdatingLocation];
}

My problem is that if the user turns on airplane mode, these methods don't detect that the GPS is unavailable, and it ends with errors.

I try to add SBUsesNetwork in my plist file, but without success.

I found some threads talking about Reachability (that I use to check the internet connection), but it is not an option since the user can disable his connection to internet (a tourist, e.g) but still want GPS location ?

How can I know if the airplane mode is activated ?

Community
  • 1
  • 1
Oyashiro
  • 505
  • 5
  • 18
  • 2
    "it ends with errors" - whenever asking a question on Stack Overflow, if you are trying to resolve errors, post the errors you are getting. – Jim Jul 27 '12 at 12:30
  • Well, what I mean is that it calls `connection:finishedWithError:`, which is logic as the phone is on airplane mode. But the error is : `Error Domain=kCLErrorDomain Code=0 "The operation couldn't be completed (kCLErrorDomain error 0.)"` – Oyashiro Jul 27 '12 at 12:33
  • Then where is the problem? It's correctly reporting that it cannot provide updates. How you handle that condition is up to you. – Jim Jul 27 '12 at 12:35
  • I'd like to avoid allocating a locationManager not to use it, but I think I'll do that anyway, if I can't find a better way to do it. – Oyashiro Jul 27 '12 at 12:39
  • @Jim Also, I'm already checking the internet connection, and I wanted to display only one alert saying that the internet connection and/or the GPS is disable. – Oyashiro Jul 27 '12 at 12:45
  • this is very close to your: http://stackoverflow.com/questions/4804398/detect-airplane-mode-on-ios/ – Vikash Rajput Nov 29 '16 at 11:26

0 Answers0