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

Fix setAudioRoutes method in ios #811

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions ios/RNCallKeep/RNCallKeep.m
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,17 @@ + (void)setup:(NSDictionary *)options {
@try {
NSError* err = nil;
AVAudioSession* myAudioSession = [AVAudioSession sharedInstance];
[myAudioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&err];

if ([inputName isEqualToString:@"Speaker"]) {
BOOL isOverrided = [myAudioSession overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&err];

[myAudioSession setActive:YES error:&err];

if(!isOverrided){
[NSException raise:@"overrideOutputAudioPort failed" format:@"error: %@", err];
}

resolve(@"Speaker");
return;
}
Expand All @@ -528,9 +534,13 @@ + (void)setup:(NSDictionary *)options {
for (AVAudioSessionPortDescription *port in ports) {
if ([port.portName isEqualToString:inputName]) {
BOOL isSetted = [myAudioSession setPreferredInput:(AVAudioSessionPortDescription *)port error:&err];

[myAudioSession setActive:YES error:&err];

if(!isSetted){
[NSException raise:@"setPreferredInput failed" format:@"error: %@", err];
}

resolve(inputName);
return;
}
Expand Down