Hir*_*ati 5 iphone objective-c openurl ios ios9
我找到了需要添加一些代码的解决方案info.plist.我这样做如下:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tel</string>
</array>
Run Code Online (Sandbox Code Playgroud)
仍然没有帮助.我收到此错误:
"-canOpenURL:URL失败:"tel:// 4806501708" - 错误:"此应用程序不允许查询方案电话"
我打开拨号器的代码:
NSString *phoneNumber = [@"tel://" stringByAppendingString:lblVenPhoneValue.text];
if ([UIApplication.sharedApplication canOpenURL:[NSURL URLWithString:phoneNumber]]) {
[UIApplication.sharedApplication openURL:[NSURL URLWithString:phoneNumber]];
Run Code Online (Sandbox Code Playgroud)
我需要做什么?
提前致谢
MOH*_*HAQ 12
你在设备上测试这个吗?,因为这不适用于模拟器.设备也应该有SIM卡.
确认以上后尝试以下
在info.plist中
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tel</string>
<string>telprompt</string>
</array>
Run Code Online (Sandbox Code Playgroud)
哪里想打开手机拨号器
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",@"digits"]]];
Run Code Online (Sandbox Code Playgroud)
要么
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@",@"digits"]]];
Run Code Online (Sandbox Code Playgroud)
小智 1
只需从@“tel://”中删除“//”就可以了
NSString *phoneNumber = [@"tel:" stringByAppendingString:lblVenPhoneValue.text];
if ([UIApplication.sharedApplication canOpenURL:[NSURL URLWithString:phoneNumber]]) {
[UIApplication.sharedApplication openURL:[NSURL URLWithString:phoneNumber]];
Run Code Online (Sandbox Code Playgroud)
为了进行更多更好的检查,您可以使用
if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:[NSString stringWithFormat:phoneNumber]]])
{
CTTelephonyNetworkInfo *networkInfo = [CTTelephonyNetworkInfo new];
CTCarrier *carrier = [networkInfo subscriberCellularProvider];
NSString *_code = [carrier mobileNetworkCode];
if(_code)
{
[[UIApplication sharedApplication] openURL:phoneNumber]];
}
else
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"no_sim" message:@"" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
[alert show];
}
}
else
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"alert" message:@"alert_device_not_support" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
[alert show];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8212 次 |
| 最近记录: |