13

In many applications, such as the Mail app, if the device is in airplane mode a notification will pop up that says "Turn Off Airplane Mode or Use Wi-Fi to Access Data."

I thought that this would automatically be invoked if my app tries to access the internet, but it is not. Is there a special method to do this, or if not how can I check if the device is in airplane mode and provide a link to Settings to disable it?

dgund
  • 3,459
  • 4
  • 39
  • 64

5 Answers5

24

If you add the UIRequiresPersistentWifi key to your Info.plist and set it to YES, then if you're in Airplane mode, you'll get the standard "Turn Off Airplane Mode..." popup on launch.

Jason Moore
  • 7,169
  • 1
  • 44
  • 45
5

I test in my app. I find it changed. "UIRequiresPersistentWifi" => "Application uses Wi-Fi". I hope it will help somebody.

xCode Target Properties

Jay
  • 4,240
  • 3
  • 26
  • 39
user1302282
  • 51
  • 2
  • 2
2

You could use the apple's reachablity framework when you app launches to check for network connectivity. Check this out

http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html

I have a wrapper class for reachbiltiy APIs to make it simpler to use. (ASIHTTPRequest has one as well).

https://github.com/daltoniam/GPHTTPRequest

see the GPReachablity class for checking for connectivity. As far as a dialog prompt, not sure there is a way to push to the settings app. Any questions let me know.

daltoniam
  • 579
  • 7
  • 13
  • There are cases when there is reception but no internet connectivity and it will be false positive as an airplane mode. If you are developing NOT for Apple's market then you can use the private API: http://stackoverflow.com/a/31583945/4260691 to get the signal strength and now when an event is fired you can check for the signal strength in the NotReachable case. If the signal strength is zero then it is a 100% airplane mode. – OhadM Feb 17 '16 at 15:53
2

If you want the standard Turn Off Airplane Mode or Use Wi-Fi to Access Data [settings | ok]

  1. Add a new property in your info.plist by clicking the + sign at the top.
  2. The new property is called UIRequiresPersistentWiFi (this is similar to postings above, but needs to be exact otherwise it doesn't register)
  3. Change type from String to Boolean
  4. Change value from NO to YES
  5. Clean and rebuild your app
veducm
  • 5,933
  • 2
  • 34
  • 40
Ali
  • 837
  • 7
  • 5
0

Take a look at this. Apparently, Airport control was moved by Apple into a separate framework

It seems there is no standard way to notify the user to turn airplane mode back on. As you mentioned, this obviously isn't very elegant, so I assume apple deleted this feature.

Imirak
  • 1,323
  • 11
  • 21
  • That's from 2009 and uses all kinds of backdoors. I suspect the real answer is "No way". I've had a bug in on this for like 3 years now - I think Apple dupped it. – David H Aug 14 '12 at 21:57
  • Well I mean I think this still works, even though it isn't very elegant. – Imirak Aug 14 '12 at 22:04