Code, Code, Revolution!
I just got my (fist) app rejected for App Store by Apple because it relies heavily on the internet connection being available and I didn’t have an information screen about the iPhone being in flight mode so the application wouldn’t do much. In my opinion only an idiot wouldn’t understand that an internet application wasn’t going to work with everything shut down but fair enough, i started hunting for code to detect flight mode.
Of course the developer pages Apple provide doesn’t give any hints. There’s an example on how to check which type of connection was available and that way I did implement an alert informing the user that they had to disable flight mode. But I couldn’t find a way to make the alert as sexy as Safari, with a button to open settings directly in the alert. It reads: “Turn off Airplane Mode or use Wi-Fi to access data”. After lots of searching Google I found out that to get the sexy Safari style alert you don’t need to write any code at all! It’s as simple as adding a property named “SBUsesNetwork” in the plist file for my app and the alert comes up automatically when the application launches. Here’s a screenshot of the plist setting:

It should be of type Boolean.
With this blog I try to provide useful tips and solutions for programming .NET, Objective-C and more. My name is Björn Sållarp, and I love writing code.
Christopher Price
July 3rd, 2009 at 10:32 pm
Apple seems to be wise to this, it doesn’t work for approval anymore. The SBUsesNetwork code only applies if Airplane Mode is turned on.
It does not apply if you are on an iPod touch with Wi-Fi off, or on an iPhone with no cellular signal.
The only sample code apple applies is their “Reachability” demo app. It’s up to you to implement the code to error prompt when internet is/isn’t available.
If your app is already approved, Apple appears to be letting some get a pass on not adding the code… but if your app isn’t approved yet… this isn’t enough anymore.
Brian Egge
October 14th, 2009 at 9:18 pm
Thanks. I had an app which uses MapKit, and was initially rejected due to the network issue. I added the SBUsesNetwork flag, and it was approved Sept 16. I then submitted a Pro version of the app, and it was rejected today.
John Stratoudakis
November 26th, 2009 at 8:01 am
I’m working on an app, and this option still helps because now my app is cool because it warns about “Airplane Mode”, and because I now have less work to do, mainly in dealing with the situations where the WWAN is not working, and when WiFi is working, but not able to reach my target host. So I am now reading about the UIAlertView class.
Thanks for posting this.
GopiKrishnaAn
June 8th, 2010 at 8:09 am
Thanks Björn Sållarp!
I was searching to detect airplane mode in iPhone..And my search ended in this page.. When I tried to include SBUsesNetwork in my plist, It didn’t show it in the dropdown. but there I found another property, “Application uses Wi-Fi ” and I set that Boolean to YES, now it works well!! This is Just FYI..
Thank you for posting this!!
steve
July 28th, 2010 at 7:31 pm
Hello, my app has been rejected one day after approval due to crash when airplane mode is active. But app does not use any wifi or network, it needs to dial a number or send a sms, so I’d need to detect airplane mode to abort before app calls the telephone api…
SBUsesNetwork can’t help because if you tap ok airplane mode is still active, app quits iphone takes control and trying to dial the number, a panel indicating you in airmode pops up again and if you tap ok it simply crashes… mah
Why they did not provided a way to check that flag?
Any idea? help please…