我想在iPhone上拨打## 8004664411这样的电话号码。
I want to dial a phone number like "##8004664411" in IPhone.
如果我拨打号码8004664411,它可以正常工作。但是如果这个号码包含符号##,它不起作用。
If I dial the number "8004664411",it works.But if the number contains the symbol"##",it doesn't work.
这是我正在使用的代码不起作用:
Here is the code that I am using which is not working:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://##8004664411"]];转义字符是否错误?
推荐答案我担心您根本无法拨打包含*或#字符的号码。出于安全原因,Apple似乎不允许使用拨号字符串。以下是文档的相关部分。
I am afraid that you simply cannot dial a number containing * or # characters. It seems that Apple doesn't allow them in a dial string for security reasons. Below is the relevant part of the documentation.
来自Apple的文档:
防止用户恶意重定向电话或更改电话或帐户的行为,电话应用程序支持电话方案中的大多数但不是全部的特殊字符。 具体来说,如果URL包含*或#字符,则Phone 应用程序不会尝试拨打相应的电话号码。 如果您的应用程序收到来自用户的URL字符串或未知的来源,您还应该确保URL中可能不合适的的任何特殊字符都可以正确转义。对于本地应用程序,使用stringByAddingPercentEscapesUsingEncoding: NSString方法来转义字符,它返回原始字符串的正确转义版本。
To prevent users from maliciously redirecting phone calls or changing the behavior of a phone or account, the Phone application supports most, but not all, of the special characters in the tel scheme. Specifically, if a URL contains the * or # characters, the Phone application does not attempt to dial the corresponding phone number. If your application receives URL strings from the user or an unknown source, you should also make sure that any special characters that might not be appropriate in a URL are escaped properly. For native applications, use the stringByAddingPercentEscapesUsingEncoding: method of NSString to escape characters, which returns a properly escaped version of your original string.
注意: stringByAddingPercentEscapesUsingEncoding:部分不适用于*和#(我试过了是的......)
Note: The stringByAddingPercentEscapesUsingEncoding: part does not apply to * and # (I've tried it yes...)
更多推荐
如何使用“##”拨打电话号码?
发布评论