diff --git a/actions.js b/actions.js index 645312f0..8492ac33 100644 --- a/actions.js +++ b/actions.js @@ -43,14 +43,12 @@ const didDisplayIncomingCall = handler => const didPerformSetMutedCallAction = handler => eventEmitter.addListener(RNCallKeepDidPerformSetMutedCallAction, (data) => handler(data.muted)); -const didPerformDTMFAction = handler => { - // @TODO: handle DTMF on iOS - if (isIOS) { - return; - } +const didPerformDTMFAction = handler => + eventEmitter.addListener(RNCallKeepDidPerformDTMFAction, (data) => { + const payload = isIOS ? { dtmf: data.digits, callUUID: data.callUUID } : data; - eventEmitter.addListener(RNCallKeepDidPerformDTMFAction, handler); -}; + return handler(payload); + }); export const listeners = { didReceiveStartCallAction, 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