From a04cf4afbf4a76984898549279eb69f722f4bf98 Mon Sep 17 00:00:00 2001 From: Christian Schmidt Date: Wed, 23 Jan 2019 10:26:36 +0100 Subject: [PATCH 1/2] Support DTMF events --- actions.js | 5 ----- ios/RNCallKeep/RNCallKeep.m | 13 ++++++++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/actions.js b/actions.js index 645312f0..864fe292 100644 --- a/actions.js +++ b/actions.js @@ -44,11 +44,6 @@ const didPerformSetMutedCallAction = handler => eventEmitter.addListener(RNCallKeepDidPerformSetMutedCallAction, (data) => handler(data.muted)); const didPerformDTMFAction = handler => { - // @TODO: handle DTMF on iOS - if (isIOS) { - return; - } - eventEmitter.addListener(RNCallKeepDidPerformDTMFAction, handler); }; diff --git a/ios/RNCallKeep/RNCallKeep.m b/ios/RNCallKeep/RNCallKeep.m index 7a3dd3fc..695f854d 100644 --- a/ios/RNCallKeep/RNCallKeep.m +++ b/ios/RNCallKeep/RNCallKeep.m @@ -24,6 +24,7 @@ static NSString *const RNCallKeepDidActivateAudioSession = @"RNCallKeepDidActivateAudioSession"; static NSString *const RNCallKeepDidDisplayIncomingCall = @"RNCallKeepDidDisplayIncomingCall"; static NSString *const RNCallKeepDidPerformSetMutedCallAction = @"RNCallKeepDidPerformSetMutedCallAction"; +static NSString *const RNCallKeepPerformPlayDTMFCallAction = @"RNCallKeepDidPerformDTMFAction"; @implementation RNCallKeep { @@ -67,7 +68,8 @@ - (void)dealloc RNCallKeepPerformEndCallAction, RNCallKeepDidActivateAudioSession, RNCallKeepDidDisplayIncomingCall, - RNCallKeepDidPerformSetMutedCallAction + RNCallKeepDidPerformSetMutedCallAction, + RNCallKeepPerformPlayDTMFCallAction ]; } @@ -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:RNCallKeepPerformPlayDTMFCallAction body:@{ @"digits": action.digits, @"callUUID": callUUID }]; + [action fulfill]; +} + - (void)provider:(CXProvider *)provider timedOutPerformingAction:(CXAction *)action { #ifdef DEBUG From 08088d2c7a9372fc3cccb11fecdf5a037a996d01 Mon Sep 17 00:00:00 2001 From: Emmanuel Quentin Date: Tue, 29 Jan 2019 10:32:29 -0500 Subject: [PATCH 2/2] Make ios dtmf payload as same as android --- actions.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/actions.js b/actions.js index 864fe292..8492ac33 100644 --- a/actions.js +++ b/actions.js @@ -43,9 +43,12 @@ const didDisplayIncomingCall = handler => const didPerformSetMutedCallAction = handler => eventEmitter.addListener(RNCallKeepDidPerformSetMutedCallAction, (data) => handler(data.muted)); -const didPerformDTMFAction = handler => { - eventEmitter.addListener(RNCallKeepDidPerformDTMFAction, handler); -}; +const didPerformDTMFAction = handler => + eventEmitter.addListener(RNCallKeepDidPerformDTMFAction, (data) => { + const payload = isIOS ? { dtmf: data.digits, callUUID: data.callUUID } : data; + + return handler(payload); + }); export const listeners = { didReceiveStartCallAction,