From af160e73a342e8555a51bc69c404489635ce95f5 Mon Sep 17 00:00:00 2001 From: Jerome91410 Date: Mon, 15 Feb 2021 18:50:01 +0100 Subject: [PATCH] fix: avoid isCallActive returning undefined --- index.d.ts | 3 +++ ios/RNCallKeep/RNCallKeep.m | 15 +++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index fa75eb98..ed569d55 100644 --- a/index.d.ts +++ b/index.d.ts @@ -103,6 +103,9 @@ declare module 'react-native-callkeep' { static setReachable(): void + /** + * @description isCallActive method is available only on iOS. + */ static isCallActive(uuid: string): Promise /** diff --git a/ios/RNCallKeep/RNCallKeep.m b/ios/RNCallKeep/RNCallKeep.m index 04af4039..9a3b375c 100644 --- a/ios/RNCallKeep/RNCallKeep.m +++ b/ios/RNCallKeep/RNCallKeep.m @@ -335,12 +335,19 @@ + (void)initCallKitProvider { [self requestTransaction:transaction]; } -RCT_EXPORT_METHOD(isCallActive:(NSString *)uuidString) +RCT_EXPORT_METHOD(isCallActive:(NSString *)uuidString + isCallActiveResolver:(RCTPromiseResolveBlock)resolve + rejecter:(RCTPromiseRejectBlock)reject) { #ifdef DEBUG NSLog(@"[RNCallKeep][isCallActive] uuid = %@", uuidString); #endif - [RNCallKeep isCallActive: uuidString]; + BOOL isActive = [RNCallKeep isCallActive: uuidString]; + if (isActive) { + resolve(@YES); + } else { + resolve(@NO); + } } - (void)requestTransaction:(CXTransaction *)transaction @@ -381,8 +388,8 @@ + (BOOL)isCallActive:(NSString *)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; + if([call.UUID isEqual:[[NSUUID alloc] initWithUUIDString:uuidString]]){ + return call.hasConnected; } } return false;