iOS:如何向通讯录中号码中含有特殊字符(#/*)的联系人发起呼叫?
我目前正在开发一个使用实时音频流的 iOS 应用程序,我们的用户要求提供一种功能,可以在流式传输时自动阻止来电。我知道没有 API 可以做到这一点,所以我们解决这个问题的方法是在 UI 上有一个按钮,可以自动呼叫某个号码(特定于电信提供商),从而打开或关闭来电阻止功能。它只需打开一个 tel: URL 即可完成此操作。
这一切都工作得很好,虽然它可能不是很用户友好,因为它强制用户退出应用程序,但我确实相信这是使用 iOS API 提供的工具的最优雅的解决方案。
但有一个警告,一些电信提供商没有一个短号码供人们拨打以打开或关闭此功能。他们使用含有特殊字符的长代码,例如 # 和 *。不幸的是,iOS 拒绝打开带有这些字符的 tel: URL,大概是出于安全原因。但是我想知道用户是否可以将这些号码放入联系人中,然后让 iOS 直接呼叫这些联系人?
我知道如何直接从地址簿中检索电话号码,但这没有用,因为我仍然会遇到 URL 不被接受的问题。那么有没有一种方法可以让 tel: URL 带有联系人 ID 或类似的内容?
感谢您的阅读和/或回复。 :)
I am currently working on an iOS application that uses live audio streaming, and our users have asked for a feature to automatically block incoming calls when they are streaming. I know that there is no API to do this, so the way we solved it is to have a button on the UI that automatically calls a certain number (specific to the telecom provider) that turns blocking of incoming calls on or off. It does this simply by opening a tel: URL.
This all works fine, and while it may not be very user friendly because it forces users to exit the application, I do belive it's the most elegant solution with the tools provided by the iOS API.
There is one caveat though, some telecom providers do not have a single short number that people can call to turn this feature on or off. They use instead long codes that have special characters in them, such as # and *. Unfortunately iOS refuses to open tel: URLs with those characters, presumably for security reasons. However I was wondering if it is possible for users to put those numbers into contacts and then have iOS call those contacts directly?
I know how to retrieve phone numbers from the address book directly, but that's no use because I will still have the problem of the URLs not getting accepted. So is there instead a way to, say, have tel: URL with a contact ID or something similar?
Thanks for reading and/or replying. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法从应用程序拨打 # 或 *。这是苹果公司保护我们免受坏人侵害的计划。
引用苹果的文档:
...并且转换为 ASCII 字符和其他技巧也不起作用(我尝试过)。
You can't dial # or * from an app. It's Apple's scheme to protect us from nasty people.
To quote from Apple's documentation:
...and converting to ASCII characters and other tricks doesn't work either (I tried).