某些电话号码的openURL失败

时间:2016-05-12 22:12:45

标签: ios iphone uiapplication openurl

我试图以编程方式拨打一个具有双重扩展名的号码。

当我尝试运行时,

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:2133776478,213#,213#"]]]

我得到"否"作为回应。但是当我在WhatsApp上输入这个号码时,我可以用这个号码拨打电话。

有没有更好的方法来实现这一目标?我在这里错过了什么吗?

2 个答案:

答案 0 :(得分:0)

根据the documentation

To prevent users from maliciously redirecting phone calls or changing the behavior of a phone or account, the Phone app supports most, but not all, of the special characters in the tel scheme. Specifically, if a URL contains the * or # characters, the Phone app does not attempt to dial the corresponding phone number.

我会首先尝试使用电话号码的转义版本(使用NSString:stringByAddingPercentEncodingWithAllowedCharacters:),如果失败,我会尝试删除,#字符。

答案 1 :(得分:0)

具有单个#的tel:URL工作,但就const PromptContainer = React.createClass({ getInitialState() { this; }, onInputChange(e) { this; }, render() { this; }, }); 而言,存在两个#字符是无效的URL,因为它看起来像URL包含两个锚段。这会产生NSURL NSURL。

如果对字符串进行百分比编码,则#字符只会成为URL字符串的一部分,并且一切正常:

nil
相关问题