From 1a572de8d8a5ffa13d98cfb8acc8e9654f61d67d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yunus=20Ayd=C4=B1n?= Date: Mon, 6 Jun 2022 16:38:04 +0300 Subject: [PATCH 1/2] iOS: destroyProvider method has added --- ios/RNCallKeep/RNCallKeep.h | 2 ++ ios/RNCallKeep/RNCallKeep.m | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/ios/RNCallKeep/RNCallKeep.h b/ios/RNCallKeep/RNCallKeep.h index c8e7bbdf..970a3dd8 100644 --- a/ios/RNCallKeep/RNCallKeep.h +++ b/ios/RNCallKeep/RNCallKeep.h @@ -47,4 +47,6 @@ continueUserActivity:(NSUserActivity *)userActivity + (void)setup:(NSDictionary *)options; ++ (void)destroyProvider; + @end diff --git a/ios/RNCallKeep/RNCallKeep.m b/ios/RNCallKeep/RNCallKeep.m index d74a4db8..1a300b37 100644 --- a/ios/RNCallKeep/RNCallKeep.m +++ b/ios/RNCallKeep/RNCallKeep.m @@ -187,6 +187,15 @@ + (void)setup:(NSDictionary *)options { isSetupNatively = YES; } ++ (void)destroyProvider { + if (sharedProvider != nil) { + [sharedProvider invalidate]; + sharedProvider = nil; + } + + isSetupNatively = NO; +} + RCT_EXPORT_METHOD(setup:(NSDictionary *)options) { if (isSetupNatively) { From 3fbbd1e3e542188e6b15a3c6ed9870ed490771a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yunus=20Ayd=C4=B1n?= Date: Thu, 6 Oct 2022 10:43:00 +0300 Subject: [PATCH 2/2] - iOS: Changed configureAudioSessio method. - iOS: Changed didActivateAudioSession method. These changes have made in order to avoid repeating audio session activationinconsistent bluetooth devices and set wrong audio session mode --- ios/RNCallKeep/RNCallKeep.m | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ios/RNCallKeep/RNCallKeep.m b/ios/RNCallKeep/RNCallKeep.m index 1a300b37..3479c4f4 100644 --- a/ios/RNCallKeep/RNCallKeep.m +++ b/ios/RNCallKeep/RNCallKeep.m @@ -552,7 +552,7 @@ + (NSMutableArray *) formatAudioInputs: (NSMutableArray *)inputs { NSMutableArray *newInputs = [NSMutableArray new]; NSString * selected = [RNCallKeep getSelectedAudioRoute]; - + NSMutableDictionary *speakerDict = [[NSMutableDictionary alloc]init]; [speakerDict setObject:@"Speaker" forKey:@"name"]; [speakerDict setObject:AVAudioSessionPortBuiltInSpeaker forKey:@"type"]; @@ -640,13 +640,13 @@ + (NSString *) getSelectedAudioRoute AVAudioSession* myAudioSession = [AVAudioSession sharedInstance]; AVAudioSessionRouteDescription *currentRoute = [myAudioSession currentRoute]; NSArray *selectedOutputs = currentRoute.outputs; - + AVAudioSessionPortDescription *selectedOutput = selectedOutputs[0]; - + if(selectedOutput && [selectedOutput.portType isEqualToString:AVAudioSessionPortBuiltInReceiver]) { return @"Phone"; } - + return [RNCallKeep getAudioInputType: selectedOutput.portType]; } @@ -905,7 +905,7 @@ - (void)configureAudioSession AVAudioSession* audioSession = [AVAudioSession sharedInstance]; [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:nil]; - [audioSession setMode:AVAudioSessionModeDefault error:nil]; + [audioSession setMode:AVAudioSessionModeVoiceChat error:nil]; double sampleRate = 44100.0; [audioSession setPreferredSampleRate:sampleRate error:nil]; @@ -1114,7 +1114,6 @@ - (void)provider:(CXProvider *)provider didActivateAudioSession:(AVAudioSession }; [[NSNotificationCenter defaultCenter] postNotificationName:AVAudioSessionInterruptionNotification object:nil userInfo:userInfo]; - [self configureAudioSession]; [self sendEventWithNameWrapper:RNCallKeepDidActivateAudioSession body:nil]; }