Reputation: 1193
I would like to provide the functionality whereby a user can dial a phone number by tapping a button next to a label that shows the number. I have the basic button action method:
-(IBAction)Call:(id)sender{
//Define function
}
... but I don't understand how to trigger the dialing of the phone within the method.
Upvotes: 2
Views: 5090
Reputation: 702
Swift 2.0:
func phoneCallPromptAction() {
let url = NSURL(string: "telprompt://1111111111")
UIApplication.sharedApplication().openURL(url!)
}
to ask user if he want's to call the number or just:
func phoneCallAction() {
let url = NSURL(string: "tel://1111111111")
UIApplication.sharedApplication().openURL(url!)
}
to make a call from you app directly.
Upvotes: 2
Reputation: 17081
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://18005551234"]];
Upvotes: 6