Skip to content
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
28 changes: 2 additions & 26 deletions ios/RNCallKeep/RNCallKeep.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ - (instancetype)init
NSLog(@"[RNCallKeep][init]");
#endif
if (self = [super init]) {
_shouldForceBluetooth = TRUE;
_isStartCallActionEventListenerAdded = NO;
_isReachable = NO;
if (_delayedEvents == nil) _delayedEvents = [NSMutableArray array];
Expand Down Expand Up @@ -151,12 +150,6 @@ - (void)onAudioRouteChange:(NSNotification *)notification
@"output": output,
@"reason": @(reason),
}];

if (_shouldForceBluetooth) {
// Force Bluetooth as soon as possible once onAudioRouteChange event handler finishes
_forceBluetoothTimer = [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(forceBluetoothPreferredInput:) userInfo:nil repeats:YES];
[_forceBluetoothTimer fire];
}
}

- (void)sendEventWithNameWrapper:(NSString *)name body:(id)body {
Expand Down Expand Up @@ -390,9 +383,6 @@ + (void)setup:(NSDictionary *)options {
_isAudioSessionActive = NO;
[self requestTransaction:transaction];
}

// We are ready to force the Bluetooth for new calls
_shouldForceBluetooth = true;
}

RCT_EXPORT_METHOD(setOnHold:(NSString *)uuidString :(BOOL)shouldHold)
Expand Down Expand Up @@ -554,10 +544,6 @@ + (void)setup:(NSDictionary *)options {
if ([inputName isEqualToString:@"Speaker"]) {
BOOL isOverrided = [myAudioSession overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&err];

if (isOverrided) {
_shouldForceBluetooth = FALSE;
}

if(!isOverrided){
[NSException raise:@"overrideOutputAudioPort failed" format:@"error: %@", err];
}
Expand All @@ -584,17 +570,7 @@ + (void)setup:(NSDictionary *)options {
for (AVAudioSessionPortDescription *port in ports) {
if ([port.portName isEqualToString:inputName]) {
BOOL isSetted = [myAudioSession setPreferredInput:(AVAudioSessionPortDescription *)port error:&err];

if (isSetted) {
if ([port.portType isEqualToString:AVAudioSessionPortBluetoothHFP] ||
[port.portType isEqualToString:AVAudioSessionPortBluetoothA2DP]) {
_shouldForceBluetooth = TRUE;
} else {
_shouldForceBluetooth = FALSE;
}
}

if(!isSetted){
if(!isSetted) {
[NSException raise:@"setPreferredInput failed" format:@"error: %@", err];
}
resolve(inputName);
Expand Down Expand Up @@ -971,7 +947,7 @@ - (void) forceBluetoothPreferredInput:(id)sender

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

break;
} @catch (NSException *e) {
Expand Down