Thursday, November 26, 2009

Detecting Airplane Mode on the iPhone

All,

There is a very simple way to add "airplane mode" detection to your iphone application without writing any code. You need to add a new property to your Info.plist property file called "SBUsesNetwork", set its property type to "boolean", and check the box. This will cause the iPhone to immediately present the "Disable airplane mode or use local wifi" dialog when the application starts.

To add this property, bring up Info.plist in the property list editor. Then use the "+" to add a new property. Type in the name "SBUsesNetwork" into the new property name. Then right click (ctrl-click) this property name and change its type to "boolean". Then make sure it is enabled.

Now, you may want/need to add more network detection to your application. The "Reachability" example code on the iPhone developer site provides a nice utility to help you further detect network availability. In fact, this code will allow you to monitor the availability of a specific web site and it will let you know if the reachability status changes.

Enjoy!!!

2 comments:

  1. SBUsesNetwork appears to be a 'folklore' setting which has no basis in reality. It's not in any apple docs -- can you show me any links to such a thing?

    Basically, someone reverese engineered something to do with springboard in 2008 and mentioned it in a blog (Erica Sadun, I think). From there it snowballed into a 'reqiured setting'. It's mythical!

    ReplyDelete