Skip to content
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

iOS: destroyProvider method has added #587

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
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
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