Safari Reference Library Apple Developer
Search

Phone Links

Note: Phone links are supported on iOS only.

The tel URL scheme is used to launch the Phone application and initiate dialing of the specified phone number. Tapping a telephone link on a webpage displays an alert asking if the user really wants to dial the phone number and initiates dialing if the user accepts. In a native application, opening a URL with the tel scheme initiates dialing without further prompting from the user.

You can specify phone links explicitly in both web and native iOS applications using the tel URL scheme. The following examples show the strings formatted for Safari and for a native application:

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. If your application receives URL strings from the user or an unknown source, you should also make sure that any special characters that might not be appropriate in a URL are escaped properly. For native applications, use the stringByAddingPercentEscapesUsingEncoding: method of NSString to escape characters, which returns a properly escaped version of your original string.

In Safari on iOS, telephone number detection is on by default. However, if your webpage contains numbers that can be interpreted as phone numbers, but are not phone numbers, you can turn off telephone number detection. You might also turn off telephone number detection to prevent the DOM document from being modified when parsed by the browser. To turn off telephone number detection in Safari on iOS, use the format-detection meta tag as follows:

<meta name = "format-detection" content = "telephone=no">

Listing 1 shows a simple webpage in which automatic telephone number detection is off. When displayed in Safari on iOS, the 408-555-5555 telephone number does not appear as a link. However, the 1-408-555-5555 number does appear as a link because it is in a phone link.

Listing 1  Turning telephone number detection off

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" >
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>Telephone Number Detection</title>
    <meta name = "viewport" content = "width=device-width">
     <!-- Turn off telephone number detection. -->
    <meta name = "format-detection" content = "telephone=no">
</head>
<body>
     <!-- Then use phone links to explicitly create a link. -->
     <p>A phone number: <a href="tel:1-408-555-5555">1-408-555-5555</a></p>
     <!-- Otherwise, numbers that look like phone numbers are not links. -->
     <p>Not a phone number: 1-408-555-5555</p>
</body>
</html>

iOS Note: If the Phone application is not installed on the device, opening a tel URL displays an appropriate warning message to the user.

For more information about the tel URL scheme, see RFC 2806 and RFC 2396.




Last updated: 2009-06-17

Did this document help you? Yes It's good, but... Not helpful...