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
170
170
171
171
Checks 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).
172
172
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
+
173
177
## Events
174
178
175
179
### - didReceiveStartCallAction
Original file line number Diff line number Diff line change @@ -115,6 +115,12 @@ export default class RNCallKit {
115
115
: Promise . reject ( 'RNCallKit.checkIfBusy was called from unsupported OS' ) ;
116
116
} ;
117
117
118
+ static checkSpeaker ( ) {
119
+ return Platform . OS === 'ios'
120
+ ? _RNCallKit . checkSpeaker ( )
121
+ : Promise . reject ( 'RNCallKit.checkSpeaker was called from unsupported OS' ) ;
122
+ }
123
+
118
124
/*
119
125
static setHeldCall(uuid, onHold) {
120
126
if (Platform.OS !== 'ios') return;
Original file line number Diff line number Diff line change @@ -93,6 +93,17 @@ - (void)dealloc
93
93
resolve (@(self.callKitCallController .callObserver .calls .count > 0 ));
94
94
}
95
95
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
+
96
107
#pragma mark - CXCallController call actions
97
108
98
109
// Display the incoming call to the user
You can’t perform that action at this time.
0 commit comments