How to Dial a Phone Number

Dec 12, 2009   //   by Derek van Vliet   //   Development  //  3 Comments

photo-4With so many awesome games and apps on the iPhone, it is easy to forget that it can actually be used to make phone calls. No, really, it’s true! And as is the case with so many other pieces of functionality, this is easy to accomplish with the iPhone SDK.

Like other phones, the iPhone supports the tel application protocol in URLs. This means that all we need to use is the trusty openURL method of the UIApplication class. We have previously discussed this method when pre-composing emails and, believe it or not, opening a URL.

The Code

Here is how to dial a phone number from your iPhone app in one line of code:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:555-555-5555"]];

Dialing From a Web Page

You can also put links in your web pages that dial a phone number on the iPhone by using the tel protocol like so:

<a href="tel:555-555-5555">Dial 555-555-5555</a>

3 Comments

  • [...] 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 [...]

  • is not working in my code.

    i have add this
    -(IBAction)go{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:555-555-5555"]];

    }

  • Hello,

    I would like to make this kind of link to dial a number, but when the popup appears when we click on the link, i don’t want the message to be the phone number. I would like to write something else, like for example : “you’re dialing a number” without giving the number to the user.

    Do you know how to do so ?

    Thank you.

    Harold.

Leave a comment

Our Games

Latest Tweets