ios 使用 iPhone SDK 以编程方式拨打电话号码并传递 DTMF

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/584663/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 15:40:34  来源:igfitidea点击:

Programmatically Dial a Phone number and pass DTMF using the iPhone SDK

iosphone-call

提问by L. DPenha

How do you programmatically do the following from the iPhone SDK:

您如何以编程方式从 iPhone SDK 执行以下操作:

  1. Programmatically Dial a Phone Number through the iPhone SDK

  2. Bypass the dial / cancelprompt that the iPhone brings up

  3. Send additional DTMF after the number is dialed just like how you would program pauses into a regular phone.

  1. 通过 iPhone SDK 以编程方式拨打电话号码

  2. 绕过iPhone 出现的拨号/取消提示

  3. 拨号后发送额外的 DTMF,就像您将暂停编程到普通电话一样。

I know you can make a tel://call but the issue is that it brings up the dial / cancel prompt and after that it prevents any future DTMF from being sent.

我知道您可以tel://拨打电话,但问题是它会显示拨号/取消提示,然后会阻止发送任何未来的 DTMF。

回答by Adam Davis

The iPhone SDK does NOT give you direct access to dial numbers (imagine if a 'bad' program got on your phone and dialed a pay per minute number on mute so you didn't notice).

iPhone SDK 不会让您直接访问拨号号码(想象一下,如果您的手机上安装了一个“坏”程序并在静音时拨打了每分钟付费号码,因此您没有注意到)。

However, if you use the tel link, then you should be able to send it "," characters which inserts pauses.

但是,如果您使用 tel 链接,那么您应该能够发送“,”插入停顿的字符。

So to dial 555-1212, then wait 4 seconds, then do 12345# on the touch tone you would use tel:5551212,,12345#

所以要拨 555-1212,然后等待 4 秒,然后在按键上做 12345# 你会使用 tel:5551212,,12345#

Check out https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/PhoneLinks/PhoneLinks.html

查看 https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/PhoneLinks/PhoneLinks.html

回答by AlBeebe

I dont know why everyone says you cant... you CAN!

我不知道为什么大家都说你不能......你CAN

NSString *phoneNumber = @"15555551212";
NSString *dtmfAfterPickup = @"1234";
NSString *telString = [NSString stringWithFormat:@"tel:%@,%@", phoneNumber, dtmfAfterPickup];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:telString]];

This will dial the phoneNumberbypassing the dial/cancel prompt... 1 second after the call is answered, the dtmfAfterPickupstring will be automatically dialed.

这将拨打phoneNumber的呼叫被应答后绕过拨号/取消提示...... 1秒,dtmfAfterPickup字符串将自动拨出。

Its a good idea to detect whether or not the device support phone calls

检测设备是否支持电话是个好主意

回答by AlBeebe

Per Adam's Apple developer link above, there's this RFC link that explains more about the different options for a telephone link scheme that the iPhone supports -

根据上面 Adam 的 Apple 开发人员链接,有一个 RFC 链接,它解释了有关 iPhone 支持的电话链接方案的不同选项的更多信息 -

http://www.ietf.org/rfc/rfc2806.txt

http://www.ietf.org/rfc/rfc2806.txt

This at least allows you to insert pauses with a 'p' in the URL, but plenty of the options are specified (but not all are required) per the RFC. What else works?

这至少允许您在 URL 中插入带有“p”的暂停,但根据 RFC 指定了大量选项(但并非所有选项都是必需的)。还有什么作用?

回答by Rockford

I tried with my iPhone using CoronaSDK and openurl API. It works very well! Just do: system.openURL("tel:[phonenumber],123"). You can wait more with additinal commas. Tested with Corona SDK / iOS7.

我尝试使用 CoronaSDK 和 openurl API 使用我的 iPhone。它运作良好!只需这样做:system.openURL("tel:[phonenumber],123")。您可以使用附加逗号等待更多时间。使用 Corona SDK / iOS7 进行测试。

回答by Rockford

Actually, I just tried the following 555-555-4822 EXT 8030

实际上,我只是尝试了以下 555-555-4822 EXT 8030

And it does seem to transmit some tones even after pressing dial (the number of p's represents the number of seconds delay). However, the tones are not being responded to on the far end as expected, so something is still amiss.

即使按下拨号键,它似乎也会传输一些音调(p 的数量代表延迟的秒数)。然而,在远端没有按预期响应音调,所以仍然有些不对劲。

This does work, however, though it's a little more prone to timing problems tel: 555-555-4822, 8030. This just pauses for one second (,, would be two seconds) after connection, and then plays the 8030 tones

然而,这确实有效,尽管它更容易出现计时问题电话:555-555-4822, 8030。这只是在连接后暂停一秒钟(,,将是两秒钟),然后播放 8030 音调

回答by Alex Wayne

You can't do this. The SDK does not allow you control the phone function in this level of detail.

你不能这样做。SDK 不允许您如此详细地控制电话功能。