How To detect an internet connection with the iPhone SDK

There are several ways to problematically detect if an iPhone has an internet connection, but most of them cant tell you how the iPhone is connected to the internet.

Apple has sample code to accomplish just this task. The Reachability class is not shipped with the SDK, but is part of a sample project of the same name. http://developer.apple.com/iphone/library/samplecode/Reachability/index.html

Using the reachability class:

Set up:

  • Download the reachability project from Apple
  • Copy Reachability.h and Reachability.m to your project.
  • Add the ‘SystemConfiguration’ framework to your project.

Sample Usage:

Reachability *reachability = [Reachability sharedReachability];
 [reachability setHostName:@"www.JoshHighland.com"];
 NetworkStatus remoteHostStatus = [reachability remoteHostStatus];

if(remoteHostStatus == NotReachable) {
 //no internet connection
 }
 else if (remoteHostStatus == ReachableViaWiFiNetwork) {
 //wifi connection found
 }
 else if (remoteHostStatus == ReachableViaCarrierDataNetwork) {
 //EDGE or 3G connection found
 }

iPhone MMS, a love / hate story

iphone_messages_iconToday AT&T unlocked MMS (multi media) messaging on the iPhone. Most of the world had had MMS messaging for YEARS now on their iPhone, but due to AT&T’s restrictions and fear of the data crushing their network they have limited the number of people that you can message at a single time to 10. This includes MMS and SMS (standard text messages)!

To most people, sending a single message to 10 people might be excessive, for me, it severely limiting. I am in charge of organizing activities for several organizations, social groups, and occasionally my church. The ability to send a single message to a large group of people has been so handy. Now if I need to send a txt message to 50 people, I’m going to have to send the same message 5 times. Talk about a step backwards!

Apple has also modified the messaging applications so you have to pick the phone number for the person you are trying to text, even if the contact only has one number. Before the MMS update, if only one phone number was in the contact, it would be used. The number of clicks has increased from 1 to 2. So, texting 10 people now requires 20 clicks instead of 10. Double the effort. I can’t see how this is progress. It feels like AT&T and Apple don’t want people to send as many text messages, so they are making it harder to do.

Dear AT&T thank you for giving up MMS messaging after all these year, but please give us back our mass texting abilities!