3.13. Initiating Phone Calls

As was just demonstrated, the openURL method calls Safari to launch website URLs. What's actually going on is this: each protocol is associated with a specific handler application. URLs beginning with http:// and https:// are associated with Safari and cause it to open whenever openURL is called using those protocol prefixes. Just as openURL can be used to open websites in Safari, it can also be used to place phone calls. To do this, use the protocol prefix of tel:.

NSURL *url = [ [ NSURL alloc ]
    initWithString: @"tel:212-555-1234" ];
[ [ UIApplication sharedApplication ] openURL: url ];

When the openURL method is used on a URL beginning with tel:, the phone application will be launched and the call will be automatically placed. Do try and ensure that your application doesn't have any bugs that cause it to accidentally place expensive overseas calls or make prank calls to the White House.