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..3479c4f4 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) { @@ -543,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"]; @@ -631,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]; } @@ -896,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]; @@ -1105,7 +1114,6 @@ - (void)provider:(CXProvider *)provider didActivateAudioSession:(AVAudioSession }; [[NSNotificationCenter defaultCenter] postNotificationName:AVAudioSessionInterruptionNotification object:nil userInfo:userInfo]; - [self configureAudioSession]; [self sendEventWithNameWrapper:RNCallKeepDidActivateAudioSession body:nil]; }