This repository was archived by the owner on May 26, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,10 @@ Switch the mic on/off
170170
171171Checks if there are any active calls on the device and returns a promise with a boolean value (` true ` if there're active calls, ` false ` otherwise).
172172
173+ ### checkSpeaker
174+
175+ Checks if the device speaker is on and returns a promise with a boolean value (` true ` if speaker is on, ` false ` otherwise).
176+
173177## Events
174178
175179### - didReceiveStartCallAction
Original file line number Diff line number Diff line change @@ -115,6 +115,12 @@ export default class RNCallKit {
115115 : Promise . reject ( 'RNCallKit.checkIfBusy was called from unsupported OS' ) ;
116116 } ;
117117
118+ static checkSpeaker ( ) {
119+ return Platform . OS === 'ios'
120+ ? _RNCallKit . checkSpeaker ( )
121+ : Promise . reject ( 'RNCallKit.checkSpeaker was called from unsupported OS' ) ;
122+ }
123+
118124 /*
119125 static setHeldCall(uuid, onHold) {
120126 if (Platform.OS !== 'ios') return;
Original file line number Diff line number Diff line change @@ -93,6 +93,17 @@ - (void)dealloc
9393 resolve (@(self.callKitCallController .callObserver .calls .count > 0 ));
9494}
9595
96+ RCT_REMAP_METHOD (checkSpeaker,
97+ checkSpeakerResolver:(RCTPromiseResolveBlock)resolve
98+ rejecter:(RCTPromiseRejectBlock)reject)
99+ {
100+ #ifdef DEBUG
101+ NSLog (@" [RNCallKit][checkSpeaker]" );
102+ #endif
103+ NSString *output = [AVAudioSession sharedInstance ].currentRoute .outputs .count > 0 ? [AVAudioSession sharedInstance ].currentRoute .outputs [0 ].portType : nil ;
104+ resolve (@([output isEqualToString: @" Speaker" ]));
105+ }
106+
96107#pragma mark - CXCallController call actions
97108
98109// Display the incoming call to the user
You can’t perform that action at this time.
0 commit comments