Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3e912d4

Browse files
authoredMay 15, 2020
Merge pull request #172 from ajnozari/master
New Method Check if Active Call with UUID
2 parents 5b37f2d + 095a34c commit 3e912d4

File tree

5 files changed

+44
-0
lines changed

5 files changed

+44
-0
lines changed
 

‎README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,21 @@ Be sure to set this only after your call is ready for two way audio; used both i
136136
RNCallKeep.setCurrentCallActive(uuid);
137137
```
138138

139+
- `uuid`: string
140+
- The `uuid` used for `startCall` or `displayIncomingCall`
141+
142+
### isCallActive
143+
_This feature is available only on IOS._
144+
145+
Returns true if the UUID passed matches an existing and answered call.
146+
This will return true ONLY if the call exists and the user has already answered the call. It will return false
147+
if the call does not exist or has not been answered. This is exposed to both React Native and Native sides.
148+
This was exposed so a call can be canceled if ringing and the user answered on a different device.
149+
150+
```js
151+
RNCallKeep.isCallActive(uuid);
152+
```
153+
139154
- `uuid`: string
140155
- The `uuid` used for `startCall` or `displayIncomingCall`
141156

‎index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ export default class RNCallKeep {
114114
static setReachable() {
115115

116116
}
117+
static isCallActive(uuid: string): Promise<boolean> {
117118

119+
}
118120
/**
119121
* @description supportConnectionService method is available only on Android.
120122
*/

‎index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ class RNCallKeep {
108108
}
109109
};
110110

111+
isCallActive = async(uuid) => await RNCallKeepModule.isCallActive(uuid);
112+
111113
endCall = (uuid) => RNCallKeepModule.endCall(uuid);
112114

113115
endAllCalls = () => RNCallKeepModule.endAllCalls();

‎ios/RNCallKeep/RNCallKeep.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,7 @@ continueUserActivity:(NSUserActivity *)userActivity
4646

4747
+ (void)endCallWithUUID:(NSString *)uuidString
4848
reason:(int)reason;
49+
50+
+ (BOOL)isCallActive:(NSString *)uuidString;
51+
4952
@end

‎ios/RNCallKeep/RNCallKeep.m

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,14 @@ + (void)initCallKitProvider {
273273
[self requestTransaction:transaction];
274274
}
275275

276+
RCT_EXPORT_METHOD(isCallActive:(NSString *)uuidString)
277+
{
278+
#ifdef DEBUG
279+
NSLog(@"[RNCallKeep][isCallActive] uuid = %@", uuidString);
280+
#endif
281+
[RNCallKeep isCallActive: uuidString];
282+
}
283+
276284
- (void)requestTransaction:(CXTransaction *)transaction
277285
{
278286
#ifdef DEBUG
@@ -304,6 +312,20 @@ - (void)requestTransaction:(CXTransaction *)transaction
304312
}];
305313
}
306314

315+
+ (BOOL)isCallActive:(NSString *)uuidString
316+
{
317+
CXCallObserver *callObserver = [[CXCallObserver alloc] init];
318+
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidString];
319+
320+
for(CXCall *call in callObserver.calls){
321+
NSLog(@"[RNCallKeep] isCallActive %@ %d ?", call.UUID, [call.UUID isEqual:uuid]);
322+
if([call.UUID isEqual:[[NSUUID alloc] initWithUUIDString:uuidString]] && !call.hasConnected){
323+
return true;
324+
}
325+
}
326+
return false;
327+
}
328+
307329
+ (void)endCallWithUUID:(NSString *)uuidString
308330
reason:(int)reason
309331
{

0 commit comments

Comments
 (0)
Please sign in to comment.