Skip to content

Add DTMF support on IOS #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2019
Merged
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
12 changes: 5 additions & 7 deletions actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 12 additions & 1 deletion ios/RNCallKeep/RNCallKeep.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -67,7 +68,8 @@ - (void)dealloc
RNCallKeepPerformEndCallAction,
RNCallKeepDidActivateAudioSession,
RNCallKeepDidDisplayIncomingCall,
RNCallKeepDidPerformSetMutedCallAction
RNCallKeepDidPerformSetMutedCallAction,
RNCallKeepPerformPlayDTMFCallAction
];
}

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:RNCallKeepPerformPlayDTMFCallAction body:@{ @"digits": action.digits, @"callUUID": callUUID }];
[action fulfill];
}

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