Skip to content

Commit 24fa3c2

Browse files
authored
Merge pull request #519 from 72days/feat/add-incoming-call-error-code
Feat/add incoming call error code (iOS)
2 parents 2d95825 + 4e15364 commit 24fa3c2

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,8 @@ RNCallKeep.addEventListener('didDisplayIncomingCall', ({ error, callUUID, handle
768768

769769
- `error` (string)
770770
- iOS only.
771+
- `errorCode` (string)
772+
- iOS only. Possible values: "Unentitled", "CallUUIDAlreadyExists", "FilteredByDoNotDisturb", "FilteredByBlockList", "Unknown". See https://developer.apple.com/documentation/callkit/cxerrorcodeincomingcallerror for more information.
771773
- `callUUID` (string)
772774
- The UUID of the call.
773775
- `handle` (string)

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;
@@ -682,6 +683,7 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
682683
RNCallKeep *callKeep = [RNCallKeep allocWithZone: nil];
683684
[callKeep sendEventWithNameWrapper:RNCallKeepDidDisplayIncomingCall body:@{
684685
@"error": error && error.localizedDescription ? error.localizedDescription : @"",
686+
@"errorCode": error ? [callKeep getIncomingCallErrorCode:error] : @"",
685687
@"callUUID": uuidString,
686688
@"handle": handle,
687689
@"localizedCallerName": localizedCallerName ? localizedCallerName : @"",
@@ -705,6 +707,21 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
705707
}];
706708
}
707709

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

0 commit comments

Comments
 (0)