Skip to content

Commit 2da7e8b

Browse files
author
Sylvain Boily
authored
Merge pull request #364 from Jerome91410/fix-isCallActive-returns
fix: avoid isCallActive returning undefined
2 parents c64ec3e + af160e7 commit 2da7e8b

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ declare module 'react-native-callkeep' {
104104

105105
static setReachable(): void
106106

107+
/**
108+
* @description isCallActive method is available only on iOS.
109+
*/
107110
static isCallActive(uuid: string): Promise<boolean>
108111

109112
/**

ios/RNCallKeep/RNCallKeep.m

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,19 @@ + (void)initCallKitProvider {
335335
[self requestTransaction:transaction];
336336
}
337337

338-
RCT_EXPORT_METHOD(isCallActive:(NSString *)uuidString)
338+
RCT_EXPORT_METHOD(isCallActive:(NSString *)uuidString
339+
isCallActiveResolver:(RCTPromiseResolveBlock)resolve
340+
rejecter:(RCTPromiseRejectBlock)reject)
339341
{
340342
#ifdef DEBUG
341343
NSLog(@"[RNCallKeep][isCallActive] uuid = %@", uuidString);
342344
#endif
343-
[RNCallKeep isCallActive: uuidString];
345+
BOOL isActive = [RNCallKeep isCallActive: uuidString];
346+
if (isActive) {
347+
resolve(@YES);
348+
} else {
349+
resolve(@NO);
350+
}
344351
}
345352

346353
- (void)requestTransaction:(CXTransaction *)transaction
@@ -381,8 +388,8 @@ + (BOOL)isCallActive:(NSString *)uuidString
381388

382389
for(CXCall *call in callObserver.calls){
383390
NSLog(@"[RNCallKeep] isCallActive %@ %d ?", call.UUID, [call.UUID isEqual:uuid]);
384-
if([call.UUID isEqual:[[NSUUID alloc] initWithUUIDString:uuidString]] && !call.hasConnected){
385-
return true;
391+
if([call.UUID isEqual:[[NSUUID alloc] initWithUUIDString:uuidString]]){
392+
return call.hasConnected;
386393
}
387394
}
388395
return false;

0 commit comments

Comments
 (0)