Skip to content
This repository has been archived by the owner on May 26, 2019. It is now read-only.

Commit

Permalink
Method for checking speaker status (#41)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
aarkalyk authored and ianlin committed May 2, 2018
1 parent 41b3147 commit c09fb17
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -170,6 +170,10 @@ Switch the mic on/off

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

### checkSpeaker

Checks if the device speaker is on and returns a promise with a boolean value (`true` if speaker is on, `false` otherwise).

## Events

### - didReceiveStartCallAction
Expand Down
6 changes: 6 additions & 0 deletions index.js
Expand Up @@ -115,6 +115,12 @@ export default class RNCallKit {
: Promise.reject('RNCallKit.checkIfBusy was called from unsupported OS');
};

static checkSpeaker() {
return Platform.OS === 'ios'
? _RNCallKit.checkSpeaker()
: Promise.reject('RNCallKit.checkSpeaker was called from unsupported OS');
}

/*
static setHeldCall(uuid, onHold) {
if (Platform.OS !== 'ios') return;
Expand Down
11 changes: 11 additions & 0 deletions ios/RNCallKit/RNCallKit.m
Expand Up @@ -93,6 +93,17 @@ - (void)dealloc
resolve(@(self.callKitCallController.callObserver.calls.count > 0));
}

RCT_REMAP_METHOD(checkSpeaker,
checkSpeakerResolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
{
#ifdef DEBUG
NSLog(@"[RNCallKit][checkSpeaker]");
#endif
NSString *output = [AVAudioSession sharedInstance].currentRoute.outputs.count > 0 ? [AVAudioSession sharedInstance].currentRoute.outputs[0].portType : nil;
resolve(@([output isEqualToString:@"Speaker"]));
}

#pragma mark - CXCallController call actions

// Display the incoming call to the user
Expand Down

0 comments on commit c09fb17

Please sign in to comment.