使用tel:URL发起呼叫的问题 [英] problem using tel: URL to initiate a call

查看:259
本文介绍了使用tel:URL发起呼叫的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试图通过iPhone应用程序发起呼叫。

I'm trying to initiate a call from within an iPhone app.

此相关代码可按预期运行并打开Safari:

This related code works and opens Safari as expected:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.apple.com"]];

但是,当我用tel URL替换http URL时,生成的代码不会调用手机应用程序:

But, when I replace the http URL with a tel URL the resulting code does not invoke the phone app:

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

不会生成异常或警报(在模拟器或设备上)。

No exceptions or alerts are generated (in the simulator or on a device).

知道我的调用可能出现什么问题?

Any idea what the problem might be with my invocation?

谢谢。

推荐答案

iphone将使用下面列出的任一格式拨打号码。 但是,如果你在模拟器中,它将无能为力。我花了30分钟的时间来解决这个问题。

The iphone will dial a number using either of the formats listed below. But, it will do nothing if you are in the simulator. It took me 30 minutes of banging my head to figure this out.

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

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

[[UIApplication sharedApplication] 
                    openURL:[NSURL URLWithString:@"tel:1-541-555-1234"]];

关于tel:url方案的Apple文档链接

openURL文档的链接

这篇关于使用tel:URL发起呼叫的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆