Reputation: 45
I tried following code but it is not working
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",@"55698"]]];
Please provide help which support iOS7 SDK.
Upvotes: 4
Views: 10646
Reputation: 1477
Updated for Swift and iOS 10 and up, where phone number is a string
//call Phone dialer
if let url = URL(string: "tel://\(phoneNumber)"), UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
Upvotes: 1
Reputation: 123
In Swift 2.0 - >= iOS 7.0 , you can use the following:
let url:NSURL = NSURL(string: "tel://9809088798")!
if (UIApplication.sharedApplication().canOpenURL(url))
{
UIApplication.sharedApplication().openURL(url)
}
Upvotes: 3
Reputation: 21378
Above answers are fine. Still please log, you have some Blank space
(@" "
) left in front or back of the Phone number string. I was facing same problem and getting the error like this:
LaunchServices: ERROR: There is no registered handler for URL scheme (null)
Then I have added that code and Open the Prompt dialler like the Below code
NSString *strPhone=[[[dictEvent valueForKey:@"app_contact_value"] stringByReplacingOccurrencesOfString:@"+" withString:@""] stringByReplacingOccurrencesOfString:@" " withString:@""];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@",strPhone]]];
and now it is Running fine.
You can also directly call with phone number like other answers:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@",strPhone]]];
Upvotes: 4
Reputation: 11217
Try this simple code:
NSURL *URL = [NSURL URLWithString:@"tel://55698"];
[[UIApplication sharedApplication] openURL:URL];
Try it out in device not in simulator...
Upvotes: 3
Reputation: 3399
Do not use tel://
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:55698"]]];
Upvotes: 1
Reputation: 244
You can place a call through the phone app using
NSString *phoneNumber = @"tel://472490168092";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
You cannot open the keypad within the phone app in iOS.You can design your own phone pad in your view controller, add tones for keys. That's the only way to achieve this AFAIK.
Upvotes: 2
Reputation: 1730
Remove // after tel: in your code
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:55698"]];
OR
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",@"55698"]]];
Upvotes: 7