Skip to content

Commit e6f9099

Browse files
author
Chris Pitt
committed
Add error code to didDisplayIncomingCall event payload.
1 parent 0f04cb0 commit e6f9099

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

ios/RNCallKeep/RNCallKeep.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#import <React/RCTLog.h>
1616

1717
#import <AVFoundation/AVAudioSession.h>
18+
#import <CallKit/CallKit.h>
1819

1920
#ifdef DEBUG
2021
static int const OUTGOING_CALL_WAKEUP_DELAY = 10;
@@ -681,6 +682,7 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
681682
RNCallKeep *callKeep = [RNCallKeep allocWithZone: nil];
682683
[callKeep sendEventWithNameWrapper:RNCallKeepDidDisplayIncomingCall body:@{
683684
@"error": error && error.localizedDescription ? error.localizedDescription : @"",
685+
@"errorCode": error ? [callKeep getIncomingCallErrorCode:error] : @"",
684686
@"callUUID": uuidString,
685687
@"handle": handle,
686688
@"localizedCallerName": localizedCallerName ? localizedCallerName : @"",
@@ -704,6 +706,21 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
704706
}];
705707
}
706708

709+
- (NSString *)getIncomingCallErrorCode:(NSError *)error {
710+
if ([error code] == CXErrorCodeIncomingCallErrorUnentitled) {
711+
return @"Unentitled";
712+
} else if ([error code] == CXErrorCodeIncomingCallErrorCallUUIDAlreadyExists) {
713+
return @"CallUUIDAlreadyExists";
714+
} else if ([error code] == CXErrorCodeIncomingCallErrorFilteredByDoNotDisturb) {
715+
return @"FilteredByDoNotDisturb";
716+
} else if ([error code] == CXErrorCodeIncomingCallErrorFilteredByBlockList) {
717+
return @"FilteredByBlockList";
718+
} else {
719+
return @"Unknown";
720+
}
721+
}
722+
723+
707724
- (BOOL)lessThanIos10_2
708725
{
709726
if (_version.majorVersion < 10) {

0 commit comments

Comments
 (0)