Join us in San Francisco on the 29/30th of October for two days of developer workshops and technical talks

Send and Receive DTMF

Overview

Dual Tone Multi Frequency (DTMF), is a form of signalling used by phone systems to transmit the digits 0-9 and the * and # characters. Typically a caller presses these buttons on their telephone keypad and the phone then generates a tone made up of two frequencies played simultaneously (hence Dual Tone).

DTMF is used both for dialing a destination on a landline telephone and also for signalling to the remote end once a call is answered. Typically this is used to implement an Interactive Voice Response (IVR) system, or to enter information like a PIN number or conference call pin.

With Nexmo Client SDKs you can both collect a DTMF input from your app user, and listen to DTMF input that was sent from another member.

Send DTMF

In order to send DTMF tones from your application to the backend, use this method:

NexmoCall.sendDTMF(dtmf: String)
nexmoCall.sendDTMF("3212333,222,399,3212333,32232,1")
[ongoingCall sendDTMF:@"3212333,222,399,3212333,32232,1"];

During an ongoing call, where your backend implemented an NCCO with an Input action, sending a DTMF will trigger the defined "eventUrl".

Receive DTMF

Whenever a member in a Conversation or a Call sends a DTMF, all of the other members are notified about that event.

The DTMF events will be received in your implementation of NexmoCallEventListener.onDTMF() method, on the NexmoCallEventListener that is attached to the NexmoCall.


callEventListener = object : NexmoCallEventListener {
    //…

    override fun onDTMF(dtmf: String, member: NexmoCallMember) {
        TODO("implement DTMF received")
    }
}

currentCall?.addCallEventListener(callEventListener)

The DTMF events will be received in the implementation of the dtmfReceived(_, callMember) optional method for your NXMCallDelegate:

func dtmfReceived(_ dtmf: String, callMember: NXMCallMember) {
  print("DTMF received:`\(dtmf)` from `\(String(describing: callMember.user.name))`")
}

The DTMF events will be received in the implementation of the DTMFReceived:callMember: optional method for your NXMCallDelegate:

- (void)DTMFReceived:(nonnull NSString *)dtmf callMember:(nonnull NXMCallMember *)callMember {
    NSLog(@"DTMF received: `%@` from `%@`", dtmf, callMember.user.name);
}