30

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

  1. Programmatically Dial a Phone Number through the iPhone SDK

  2. Bypass the dial / cancel prompt 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.

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
L. DPenha
  • 519
  • 2
  • 7
  • 8

6 Answers6

32

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).

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

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

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
Adam Davis
  • 91,931
  • 60
  • 264
  • 330
  • The problem with the tel:// method is that the Dial / Cancel prompt causes the iPhone to ignore any dtmf past the number. Do you have code where you successful past dtmf past the actual number? – L. DPenha Feb 25 '09 at 04:05
  • Reports seem to indicate that tel: urls from a webpage suffer from that issue, but real applications don't: http://forums.macrumors.com/showthread.php?t=484177 Are you trying to create an iPhone app, or webapp? – Adam Davis Feb 25 '09 at 04:07
  • This is an SDK based iPhone application but my initial testing was around the webpage tel:// calls. I'll try the DTMF in the SDK – L. DPenha Feb 25 '09 at 04:12
  • Thanks you. It's very useful with me. – PhatHV Nov 09 '12 at 02:45
  • 1
    When you say wait 4 seconds, are those two commas responsible for that? What I tested is, I had to call 121 and then press 2 and then 4. For that I just use 121,2,4. first 121 is dialed and when connected, 2 is tapped automatically and then 4. I don't understand why you said 4 seconds and why 4 commas – nr5 Jun 21 '19 at 11:18
18

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

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

This will dial the phoneNumber bypassing the dial/cancel prompt... 1 second after the call is answered, the dtmfAfterPickup string will be automatically dialed.

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

Community
  • 1
  • 1
AlBeebe
  • 8,101
  • 3
  • 51
  • 65
  • you can add additional 1 second pauses by inserting commas into the dtmfAfterPickup string. NSString *dtmfAfterPickup = @"1,2,3,4"; This will add a 1 second pause after each number – AlBeebe Feb 09 '11 at 09:59
  • Is there away to record a phone conversation using the API? – ThE uSeFuL Sep 13 '11 at 06:36
  • 1
    No way to record a phone call is available in the iOS SDK – AlBeebe Sep 13 '11 at 06:38
  • How about AVAudioRecorder? Can't we use that? – ThE uSeFuL Sep 13 '11 at 08:58
  • The issue with this is reliability. The comma only inserts a pause. It does not wait for pickup as suggested by the variable names. In many situations, especially with a mobile phone, it is not practical to try and predict the amount of time in which a call will pickup. That time can range from 1 - 20 seconds or even more. So, the comma may or may not work. You can add more commas, but how many do you have to add to account for 90% of the calls out there and is it practical to make your user wait for that long. It seems Apple needs a better way before it's reliable enough. – ptoinson Dec 13 '11 at 21:53
  • @ptoinson your wrong. The pauses and DTMF tones are not executed until after the call is picked up. I just tested this on iOS5 by calling a number and letting it ring for 20 seconds before answering it. As soon as i answered it, the pauses and DTMF tones were executed. I know this worked on iOS4.x as well because i utilized this code in an app and my customers never had an issue. – AlBeebe Dec 16 '11 at 19:03
  • @AlBeebe Interesting. I was not seeing this behavior. I will do some more testing. Thanks for the reply. – ptoinson Dec 20 '11 at 17:52
  • my tests on att and ios 5 confirm that the pause occurs after connection is established. AlBeebe, have you been able to test this on a Verizon phone? Reason I ask is because i cannot find docs to support the post connect nature of the pause. And gsm vs cdma have some minor diffs. Just want to have confidence before implementing an expensive app. – ptoinson Dec 21 '11 at 06:02
  • @ptoinson Just confirmed it works on Verizon running 5.0.1, the same as it does on AT&T. – AlBeebe Dec 26 '11 at 22:34
  • 2
    @Krish you can't add * or #. iOS prevents you from doing that. – AlBeebe Jul 30 '12 at 19:06
2

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 -

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?

1

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.

Rockford
  • 11
  • 2
0

Actually, I just tried the following 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.

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

-1

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

Alex Wayne
  • 178,991
  • 47
  • 309
  • 337