Pham Hoan
Pham Hoan

Reputation: 2127

How do I custom the alert view when making a phone call

currently I'm using UIWebView to make phone calls

NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel://123456789"];
[self.callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];

when I touch on a button to make call, an UIAlertView appears and ask for confirmation with title 123456789

How can I change its title and message ?

Thanks.

Upvotes: 1

Views: 892

Answers (1)

rckoenes
rckoenes

Reputation: 69499

Don't use a UIWebView, just present a UIAlertView to the user asking if he/she want to call. Also there are no // in the tel: scheme, so tel:123456789 is correct.

Then just open open the tel: url via [[UIApplication sharedApplication] openURL:telURL].

Also do not forget the check whether the users device can make phone calls:

NSURL *telURL = [NSURL URLWithString:@"tel:123456789"];

if ([[UIApplication sharedApplication] canOpenURL:telURL]) {
 // Present the user with the dialog to start the call
} else {
 // inform the user that he/she can't call numbers from their device.
}

Upvotes: 2

Related Questions