ios - 如何在 iOS 9 中打开电话拨号器?

标签 ios objective-c iphone ios9 openurl

我找到了解决方案,我需要在 info.plist 中添加一些代码。我这样做如下:

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

仍然没有帮助。 我收到此错误:

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

我打开拨号器的代码:

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

我需要做什么?
提前致谢

最佳答案

你在设备上测试这个吗? ,因为这在模拟器上不起作用。并且设备也应该有 SIM 卡。

确认以上内容后尝试以下

在 info.plist 中

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

要在哪里打开电话拨号器

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

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

关于ios - 如何在 iOS 9 中打开电话拨号器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35792681/

相关文章:

ios - 如何在另一个 ViewController 前面将 UITableViewController 显示为向上滑动手势?

ios - 在 App Store 上更新 Only iPad 应用程序

objective-c - 错误预期标识符或 (

ios - 28 个项目的数组不起作用。编译器没有任何反应

iphone - Facebook-ios-sdk 对话框立即消失

ios - 如何实现pdf编辑器

ios - 具有可调整大小图像的 UIButton setImage 与 setBackgroundImage

ios - stringByReplacingOccourencesOfString 与 NSMutableAttributedString

iphone - iOS 应用角标(Badge)仍然存在

ios - swift 3 错误 : "Binary operator ' /' cannot be applied to two ' int' operands"