Skip to content

fix: avoid isCallActive returning undefined #364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2021
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
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>

/**
Expand Down
15 changes: 11 additions & 4 deletions ios/RNCallKeep/RNCallKeep.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down