From 14626cf1401fa68b4021807deac3eff5a520e21f Mon Sep 17 00:00:00 2001 From: Christian Schmidt Date: Wed, 23 Jan 2019 10:20:31 +0100 Subject: [PATCH] Support didDeactivateAudioSession --- actions.js | 9 +++++++++ ios/RNCallKit/RNCallKit.m | 3 +++ 2 files changed, 12 insertions(+) diff --git a/actions.js b/actions.js index 7a1b234..4b75efd 100644 --- a/actions.js +++ b/actions.js @@ -10,6 +10,7 @@ const RNCallKitDidReceiveStartCallAction = 'RNCallKitDidReceiveStartCallAction'; const RNCallKitPerformAnswerCallAction = 'RNCallKitPerformAnswerCallAction'; const RNCallKitPerformEndCallAction = 'RNCallKitPerformEndCallAction'; const RNCallKitDidActivateAudioSession = 'RNCallKitDidActivateAudioSession'; +const RNCallKitDidDeactivateAudioSession = 'RNCallKitDidDeactivateAudioSession'; const RNCallKitDidDisplayIncomingCall = 'RNCallKitDidDisplayIncomingCall'; const RNCallKitDidPerformSetMutedCallAction = 'RNCallKitDidPerformSetMutedCallAction'; @@ -43,6 +44,13 @@ didActivateAudioSession = handler => ( ) ) +didDeactivateAudioSession = handler => ( + _RNCallKitEmitter.addListener( + RNCallKitDidDeactivateAudioSession, + () => { handler(); } + ) +) + didDisplayIncomingCall = handler => ( _RNCallKitEmitter.addListener( RNCallKitDidDisplayIncomingCall, @@ -62,6 +70,7 @@ export const listeners = { answerCall, endCall, didActivateAudioSession, + didDeactivateAudioSession, didDisplayIncomingCall, didPerformSetMutedCallAction, }; diff --git a/ios/RNCallKit/RNCallKit.m b/ios/RNCallKit/RNCallKit.m index fc3439f..b87102c 100644 --- a/ios/RNCallKit/RNCallKit.m +++ b/ios/RNCallKit/RNCallKit.m @@ -22,6 +22,7 @@ static NSString *const RNCallKitPerformAnswerCallAction = @"RNCallKitPerformAnswerCallAction"; static NSString *const RNCallKitPerformEndCallAction = @"RNCallKitPerformEndCallAction"; static NSString *const RNCallKitDidActivateAudioSession = @"RNCallKitDidActivateAudioSession"; +static NSString *const RNCallKitDidDeactivateAudioSession = @"RNCallKitDidDeactivateAudioSession"; static NSString *const RNCallKitDidDisplayIncomingCall = @"RNCallKitDidDisplayIncomingCall"; static NSString *const RNCallKitDidPerformSetMutedCallAction = @"RNCallKitDidPerformSetMutedCallAction"; @@ -66,6 +67,7 @@ - (void)dealloc RNCallKitPerformAnswerCallAction, RNCallKitPerformEndCallAction, RNCallKitDidActivateAudioSession, + RNCallKitDidDeactivateAudioSession, RNCallKitDidDisplayIncomingCall, RNCallKitDidPerformSetMutedCallAction ]; @@ -473,6 +475,7 @@ - (void)provider:(CXProvider *)provider didDeactivateAudioSession:(AVAudioSessio #ifdef DEBUG NSLog(@"[RNCallKit][CXProviderDelegate][provider:didDeactivateAudioSession]"); #endif + [self sendEventWithName:RNCallKitDidDeactivateAudioSession body:nil]; } -(void)provider:(CXProvider *)provider performSetMutedCallAction:(CXSetMutedCallAction *)action