Skip to content

Commit 41b3147

Browse files
aarkalykianlin
authored andcommitted
Feature / Check if phone is busy (#39)
* contactIdentifier added to startCall action. * README.md updated. * checkIfBusy method added. * README updated. * minor fixes. * checkIfBusy method moved to the bottom of index.js * minor fix * check for OS added. * synced with master
1 parent c15c147 commit 41b3147

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ Call when you finish an incoming/outgoing call
166166

167167
Switch the mic on/off
168168

169+
### checkIfBusy
170+
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+
169173
## Events
170174

171175
### - didReceiveStartCallAction

index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ export default class RNCallKit {
109109
_RNCallKit.setMutedCall(uuid, muted);
110110
}
111111

112+
static checkIfBusy() {
113+
return Platform.OS === 'ios'
114+
? _RNCallKit.checkIfBusy()
115+
: Promise.reject('RNCallKit.checkIfBusy was called from unsupported OS');
116+
};
117+
112118
/*
113119
static setHeldCall(uuid, onHold) {
114120
if (Platform.OS !== 'ios') return;

ios/RNCallKit/RNCallKit.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ - (void)dealloc
8383
[self.callKitProvider setDelegate:self queue:nil];
8484
}
8585

86+
RCT_REMAP_METHOD(checkIfBusy,
87+
checkIfBusyWithResolver:(RCTPromiseResolveBlock)resolve
88+
rejecter:(RCTPromiseRejectBlock)reject)
89+
{
90+
#ifdef DEBUG
91+
NSLog(@"[RNCallKit][checkIfBusy]");
92+
#endif
93+
resolve(@(self.callKitCallController.callObserver.calls.count > 0));
94+
}
95+
8696
#pragma mark - CXCallController call actions
8797

8898
// Display the incoming call to the user

0 commit comments

Comments
 (0)