File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -126,7 +126,11 @@ - (void)onAudioRouteChange:(NSNotification *)notification
126126{
127127 NSDictionary *info = notification.userInfo ;
128128 NSInteger reason = [[info valueForKey: AVAudioSessionRouteChangeReasonKey] integerValue ];
129- NSString *output = [AVAudioSession sharedInstance ].currentRoute .outputs .count > 0 ? [AVAudioSession sharedInstance ].currentRoute .outputs [0 ].portType : nil ;
129+ NSString *output = [RNCallKeep getAudioOutput ];
130+
131+ if (output == nil ) {
132+ return ;
133+ }
130134
131135 [self sendEventWithName: RNCallKeepDidChangeAudioRoute body: @{
132136 @" output" : output,
@@ -154,6 +158,10 @@ + (void)initCallKitProvider {
154158 }
155159}
156160
161+ + (NSString *) getAudioOutput {
162+ return [AVAudioSession sharedInstance ].currentRoute .outputs .count > 0 ? [AVAudioSession sharedInstance ].currentRoute .outputs [0 ].portType : nil ;
163+ }
164+
157165+ (void )setup : (NSDictionary *)options {
158166 RNCallKeep *callKeep = [RNCallKeep allocWithZone: nil ];
159167 [callKeep setup: options];
@@ -203,7 +211,7 @@ + (void)setup:(NSDictionary *)options {
203211#ifdef DEBUG
204212 NSLog (@" [RNCallKeep][checkSpeaker]" );
205213#endif
206- NSString *output = [AVAudioSession sharedInstance ]. currentRoute . outputs . count > 0 ? [AVAudioSession sharedInstance ]. currentRoute . outputs [ 0 ]. portType : nil ;
214+ NSString *output = [RNCallKeep getAudioOutput ] ;
207215 resolve (@([output isEqualToString: @" Speaker" ]));
208216}
209217
You can’t perform that action at this time.
0 commit comments