How can I dial a phone number that includes a number and access code programmatically in iOS?
For example:
number: 900-3440-567
Access C
There are a number of ways to dial a phone number and the way described that uses:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:555-555-5555"]
Is a valid way to do this however it has a number of issues. First it doesn't properly prompt the user and secondly it doesn't bring the user back to the application when the phone call is completed. To properly place a phone call you should both prompt before the call so you don't surprise the user and you should bring the user back to the application once the call is done.
Both of these can be accomplished without using a private API as is suggested by some of the answers here. The recommended approach uses the telprompt api but it doesn't use the private instantiation of the call and instead creates a web view allowing for future compatibility.
+ (void)callWithString:(NSString *)phoneString
{
[self callWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phoneString]]];
}
+ (void)callWithURL:(NSURL *)url
{
static UIWebView *webView = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
webView = [UIWebView new];
});
[webView loadRequest:[NSURLRequest requestWithURL:url]];
}
A sample project and additional information is provided here: http://www.raizlabs.com/dev/2014/04/getting-the-best-behavior-from-phone-call-requests-using-tel-in-an-ios-app/