Skip to content

Commit af160e7

Browse files
author
Jerome91410
committed
fix: avoid isCallActive returning undefined
1 parent 8bdddcc commit af160e7

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
@@ -103,6 +103,9 @@ declare module 'react-native-callkeep' {
103103

104104
static setReachable(): void
105105

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

108111
/**

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)