Skip to content
Closed
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
2 changes: 2 additions & 0 deletions ios/RNCallKeep/RNCallKeep.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ continueUserActivity:(NSUserActivity *)userActivity

+ (void)setup:(NSDictionary *)options;

+ (void)destroyProvider;

@end
20 changes: 14 additions & 6 deletions ios/RNCallKeep/RNCallKeep.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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"];
Expand Down Expand Up @@ -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];
}

Expand Down Expand Up @@ -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];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why changing this ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


double sampleRate = 44100.0;
[audioSession setPreferredSampleRate:sampleRate error:nil];
Expand Down Expand Up @@ -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];
}

Expand Down