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<boolean> /** 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;