How to Open the SMS App With a Phone Number

Dec 24, 2009   //   by Derek van Vliet   //   Development  //  No Comments

It’s the day before Christmas, so this is the last post in our advent tip series. We’ve really enjoyed writing about so many little things that are so easily accomplished with the iPhone SDK and we hope that they’ve helped you in developing your iPhone apps. This may be the last blog post in this series, but you can be sure we’ll still be writing about our adventures with iPhone, cocos2d and OpenFeint development.

Less Yap, More Tip

Today’s advent tip is how to open the Messages app (aka the SMS app) with a specific phone number populated in the To: field. This is accomplished with great ease because the iPhone has implemented the sms: URI scheme. Therefore, we can use the UIApplication class’ openURL method, which we have seen before when we discussed how to dial a phone number, pre-compose an email, and yes, even open a URL.

So here it is: the one line of code you need to pop open the SMS app with a phone number:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:5555555555"]];

Leave a comment

Our Games

Latest Tweets