Skip to content
This repository has been archived by the owner on May 26, 2019. It is now read-only.

Support DTMF events #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const RNCallKitPerformEndCallAction = 'RNCallKitPerformEndCallAction';
const RNCallKitDidActivateAudioSession = 'RNCallKitDidActivateAudioSession';
const RNCallKitDidDisplayIncomingCall = 'RNCallKitDidDisplayIncomingCall';
const RNCallKitDidPerformSetMutedCallAction = 'RNCallKitDidPerformSetMutedCallAction';
const RNCallKitPerformPlayDTMFCallAction = 'RNCallKitPerformPlayDTMFCallAction';

didReceiveStartCallAction = handler => {
const listener = _RNCallKitEmitter.addListener(
Expand Down Expand Up @@ -57,10 +58,18 @@ didPerformSetMutedCallAction = handler => (
)
)

playDTMF = handler => (
_RNCallKitEmitter.addListener(
RNCallKitPerformPlayDTMFCallAction,
(data) => { handler(data); }
)
)

export const listeners = {
didReceiveStartCallAction,
answerCall,
endCall,
playDTMF,
didActivateAudioSession,
didDisplayIncomingCall,
didPerformSetMutedCallAction,
Expand Down
13 changes: 12 additions & 1 deletion ios/RNCallKit/RNCallKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
static NSString *const RNCallKitDidActivateAudioSession = @"RNCallKitDidActivateAudioSession";
static NSString *const RNCallKitDidDisplayIncomingCall = @"RNCallKitDidDisplayIncomingCall";
static NSString *const RNCallKitDidPerformSetMutedCallAction = @"RNCallKitDidPerformSetMutedCallAction";
static NSString *const RNCallKitPerformPlayDTMFCallAction = @"RNCallKitPerformPlayDTMFCallAction";

@implementation RNCallKit
{
Expand Down Expand Up @@ -67,7 +68,8 @@ - (void)dealloc
RNCallKitPerformEndCallAction,
RNCallKitDidActivateAudioSession,
RNCallKitDidDisplayIncomingCall,
RNCallKitDidPerformSetMutedCallAction
RNCallKitDidPerformSetMutedCallAction,
RNCallKitPerformPlayDTMFCallAction
];
}

Expand Down Expand Up @@ -453,6 +455,15 @@ - (void)provider:(CXProvider *)provider performSetHeldCallAction:(CXSetHeldCallA
#endif
}

- (void)provider:(CXProvider *)provider performPlayDTMFCallAction:(CXPlayDTMFCallAction *)action {
#ifdef DEBUG
NSLog(@"[RNCallKit][CXProviderDelegate][provider:performPlayDTMFCallAction]");
#endif
NSString *callUUID = [self containsLowerCaseLetter:action.callUUID.UUIDString] ? action.callUUID.UUIDString : [action.callUUID.UUIDString lowercaseString];
[self sendEventWithName:RNCallKitPerformPlayDTMFCallAction body:@{ @"digits": action.digits, @"callUUID": callUUID }];
[action fulfill];
}

- (void)provider:(CXProvider *)provider timedOutPerformingAction:(CXAction *)action
{
#ifdef DEBUG
Expand Down