how to open phone dialler in iOS 9?

Hiren Prajapati picture Hiren Prajapati · Mar 4, 2016 · Viewed 11.3k times · Source

I found solution that I need to add some code in info.plist. I did it like below:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>tel</string>
</array>

still no help. I get this error:

"-canOpenURL: failed for URL: "tel://4806501708" - error: "This app is not allowed to query for scheme tel"

my code for opening dialler:

NSString *phoneNumber = [@"tel://" stringByAppendingString:lblVenPhoneValue.text];
if ([UIApplication.sharedApplication canOpenURL:[NSURL URLWithString:phoneNumber]]) {
        [UIApplication.sharedApplication openURL:[NSURL URLWithString:phoneNumber]];

What do I need to do?
Thanks in Advance

Answer

MOHAMMAD ISHAQ picture MOHAMMAD ISHAQ · Mar 4, 2016

Are you testing this on device ? , because this will not work on simulator . And device should have sim card too .

After confirming above try following

In info.plist

<key>LSApplicationQueriesSchemes</key>
<array>
<string>tel</string>
<string>telprompt</string>
</array>

Where want to open phone dialler

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",@"digits"]]]; 

or

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@",@"digits"]]];