Skip to content

Commit c09fb17

Browse files
aarkalykianlin
authored andcommitted
Method for checking speaker status (#41)
* contactIdentifier added to startCall action. * README.md updated. * checkIfBusy method added. * checkIfBusy method moved to the bottom of index.js * version 1.3.4 * publish congig added. * setMute method and event handler added. * checkSpeaker method added * package.json bugs fixed.
1 parent 41b3147 commit c09fb17

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ Switch the mic on/off
170170

171171
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).
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

index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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;

ios/RNCallKit/RNCallKit.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)