Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

open dialer in ios on click of button

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.

like image 444
Dharmendra Vaishnav Avatar asked Nov 30 '22 11:11

Dharmendra Vaishnav


2 Answers

Remove // after tel: in your code

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:55698"]];

OR

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",@"55698"]]];
like image 54
DharaParekh Avatar answered Dec 02 '22 01:12

DharaParekh


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]]];
like image 45
Manab Kumar Mal Avatar answered Dec 02 '22 02:12

Manab Kumar Mal