Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,21 @@ Be sure to set this only after your call is ready for two way audio; used both i
RNCallKeep.setCurrentCallActive(uuid);
```

- `uuid`: string
- The `uuid` used for `startCall` or `displayIncomingCall`

### isCallActive
_This feature is available only on IOS._

Returns true if the UUID passed matches an existing and answered call.
This will return true ONLY if the call exists and the user has already answered the call. It will return false
if the call does not exist or has not been answered. This is exposed to both React Native and Native sides.
This was exposed so a call can be canceled if ringing and the user answered on a different device.

```js
RNCallKeep.isCallActive(uuid);
```

- `uuid`: string
- The `uuid` used for `startCall` or `displayIncomingCall`

Expand Down
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ export default class RNCallKeep {
static setReachable() {

}
static isCallActive(uuid: string): Promise<boolean> {

}
/**
* @description supportConnectionService method is available only on Android.
*/
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ class RNCallKeep {
}
};

isCallActive = async(uuid) => await RNCallKeepModule.isCallActive(uuid);

endCall = (uuid) => RNCallKeepModule.endCall(uuid);

endAllCalls = () => RNCallKeepModule.endAllCalls();
Expand Down
3 changes: 3 additions & 0 deletions ios/RNCallKeep/RNCallKeep.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ continueUserActivity:(NSUserActivity *)userActivity

+ (void)endCallWithUUID:(NSString *)uuidString
reason:(int)reason;

+ (BOOL)isCallActive:(NSString *)uuidString;

@end
22 changes: 22 additions & 0 deletions ios/RNCallKeep/RNCallKeep.m
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,14 @@ + (void)initCallKitProvider {
[self requestTransaction:transaction];
}

RCT_EXPORT_METHOD(isCallActive:(NSString *)uuidString)
{
#ifdef DEBUG
NSLog(@"[RNCallKeep][isCallActive] uuid = %@", uuidString);
#endif
[RNCallKeep isCallActive: uuidString];
}

- (void)requestTransaction:(CXTransaction *)transaction
{
#ifdef DEBUG
Expand Down Expand Up @@ -304,6 +312,20 @@ - (void)requestTransaction:(CXTransaction *)transaction
}];
}

+ (BOOL)isCallActive:(NSString *)uuidString
{
CXCallObserver *callObserver = [[CXCallObserver alloc] init];
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidString];

for(CXCall *call in callObserver.calls){
NSLog(@"[RNCallKeep] isCallActive %@ %d ?", call.UUID, [call.UUID isEqual:uuid]);
if([call.UUID isEqual:[[NSUUID alloc] initWithUUIDString:uuidString]] && !call.hasConnected){
return true;
}
}
return false;
}

+ (void)endCallWithUUID:(NSString *)uuidString
reason:(int)reason
{
Expand Down