How to invoke "Turn Off Airplane Mode" notification
Asked Answered
S

5

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?

Sirotek answered 14/8, 2012 at 21:12 Comment(0)
P
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.

Puentes answered 21/11, 2012 at 9:1 Comment(1)
As of 2016, UIRequiresPersistentWifi has changed to "Application uses Wi-Fi" in the app settings Info section.Hereinbefore
K
5

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

xCode Target Properties

Karli answered 10/11, 2014 at 8:39 Comment(1)
As of 2016 this seems to be the most up-to-date answer here.Hereinbefore
G
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.

Gracie answered 14/8, 2012 at 22:50 Comment(1)
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: https://mcmap.net/q/903750/-calculating-ios-signal-strength-using-ctgetsignalstrength 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.Whereof
D
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
Dalt answered 10/2, 2015 at 23:0 Comment(0)
G
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.

Gather answered 14/8, 2012 at 21:44 Comment(2)
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.Derision
Well I mean I think this still works, even though it isn't very elegant.Gather

© 2022 - 2024 — McMap. All rights reserved.