我找到了解决方案,我需要在 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/