UPDATE: As of some version of iOS 8 (8.3, maybe), GPS hardware can be turned on even in airplane mode (i.e., you can get GPS location even in airplane mode). This renders this question moot.
--
Is it possible to programatically determine if an iPhone is in Airplane Mode? I specifically want to know if it's in AirPlane Mode, as opposed to having (or not having) a network connection. This question has been asked a lot, but every answer I've seen has referred to Apple's Reachability code to determine if a network connection is available.
I'm writing an app that uses the iPhone's GPS. At the moment, if Airplane Mode is on and my app is launched, my location manager object still appears to exist and still appears to be giving me a (cached?) location. The little GPS icon appears in the status bar to let me know that my app is determining a location.
I want to know if the phone's in Airplane Mode so that I can not initialise the location manager object and I can change my UI to indicate to the user that GPS functionality is not available.
The GPS functionality can obviously be used regardless of network connectivity, so a lack of network connectivity strikes me as being a poor proxy for Airplane Mode. I don't appear to get any specific errors (through locationManager: didFailWithError) when in Airplane Mode, just a generic error that I'm assuming could come from a number of sources.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…