How to make a phone call (programmatically) with the iphone (ios sdk)


this problem is very simple to solve, you will have to write only few lines of code. But you should also know some theory. We are going to solve this problem using NSURL, so a short overview (from Apple) about this class could be useful.

NSURL Overview

An NSURL object lets you manipulate URLs and the resources they reference. The URLs employed by the NSURL class are described in RFCs 1808, 1738, and 2732. The litmus test for conformance to RFC 1808 is as recommended in RFC 1808—specifically, whether the first two characters of resourceSpecifier are slashes (//).

You can use an NSURL object to refer to a file, which is the preferred way to do so. AppKit objects that can read data from or write data to a file generally have methods that accept an NSURL object instead of a pathname as the file reference. In Mac OS X, the NSWorkspace class provides openURL: to open a location specified by a URL. Similarly, in iOS, UIApplication provides openURL:. To get the contents of a URL, NSString provides stringWithContentsOfURL: and NSData provides dataWithContentsOfURL:.

An NSURL object is composed of two parts—a potentially nil base URL and a string that is resolved relative to the base URL. An NSURL object whose string is fully resolved without a base is considered absolute; all others are considered relative.

The classes NSURLConnection and NSURLDownload define methods useful for loading URL resources in the background. See URL Loading System Programming Guide for more information

Let's go on, writing some code:

// Set into a string the phone number you want to call

NSString *phone_number = "012-12345678";


// Create a string with the correct format  <tell://> <phone number>

NSString *phoneStr = [[NSString alloc] initWithFormat:@"tel://%@",phone_number];


// Prepare the NSURL

NSURL *phoneURL = [[NSURL alloc] initWithString:phoneStr];


// Make the call

[[UIApplication sharedApplication] openURL:phoneURL];

[phoneURL release];

[phoneStr release];

See you soon,


You may also like...

3 Responses

  1. HappyMan says:

    Thank you for the article 😀

  2. Saakar says:

    How do i call to number with * and # included???
    what i did is not working or supported according to RFC3966 documentation.
    i did like this but didn't worked..
    NSURL *check = [[NSURL alloc] initWithString: @"tel:*500879#"]; //specifying the no. to call. 
    [[UIApplication sharedApplication] openURL: check] /// for calling the specified no. in check variable.
    How can i do this?? any help please. I Wud be very thankful..Please.

  3. admin says:

    Hi Saakar,
    take a look at:
    To prevent users from maliciously redirecting phone calls or changing the behavior of a phone or account, the Phone application supports most, but not all, of the special characters in the tel scheme. Specifically, if a URL contains the * or # characters, the Phone application does not attempt to dial the corresponding phone number.

    The apple URL scheme conforms only to RFC2806 and RFC2396, and not to RFC3966.

    Anyway if someone has different info, I’ll be pleased to publish them.

Leave a Reply

Your email address will not be published. Required fields are marked *