Skip to content

Commit 5dfb256

Browse files
committed
add ANSWERED_ELSEWHERE end reason & constants
1 parent 1d6d537 commit 5dfb256

File tree

4 files changed

+31
-11
lines changed

4 files changed

+31
-11
lines changed

README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,13 @@ RNCallKeep.reportEndCallWithUUID(uuid, reason);
238238
- Call failed: 1
239239
- Remote user ended call: 2
240240
- Remote user did not answer: 3
241-
- `CXCallEndedReason` constants used for iOS. `DisconnectCause` used for Android.
242-
- Example enum for reasons
241+
- Call Answered elsewhere: 4
242+
- Call declined elsewhere: 5 (iOS only)
243+
- Access reasons as constants
243244
```js
244-
END_CALL_REASON = {
245-
failed: 1,
246-
remoteEnded: 2,
247-
unanswered: 3
248-
}
245+
const { CONSTANTS as CK_CONSTANTS, RNCallKeep } from 'react-native-callkeep';
246+
247+
RNCallKeep.reportEndCallWithUUID(uuid, CK_CONSTANTS.END_CALL_REASONS.FAILED);
249248
```
250249

251250
### setMutedCall
@@ -471,7 +470,7 @@ RNCallKeep.addEventListener('didPerformDTMFAction', ({ digits, callUUID }) => {
471470
- The digits that emit the dtmf tone
472471
- `callUUID` (string)
473472
- The UUID of the call.
474-
473+
475474
### - checkReachability
476475

477476
On Android when the application is in background, after a certain delay the OS will close every connection with informing about it.
@@ -611,7 +610,7 @@ class RNCallKeepExample extends React.Component {
611610
## Receiving a call when the application is not reachable.
612611

613612
In some case your application can be unreachable :
614-
- when the user kill the application
613+
- when the user kill the application
615614
- when it's in background since a long time (eg: after ~5mn the os will kill all connections).
616615

617616
To be able to wake up your application to display the incoming call, you can use [https://github.com/ianlin/react-native-voip-push-notification](react-native-voip-push-notification) on iOS or BackgroundMessaging from [react-native-firebase](https://rnfirebase.io/docs/v5.x.x/messaging/receiving-messages#4)-(Optional)(Android-only)-Listen-for-FCM-messages-in-the-background).
@@ -626,12 +625,12 @@ Since iOS 13, you'll have to report the incoming calls that wakes up your applic
626625
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion {
627626
// Process the received push
628627
[RNVoipPushNotificationManager didReceiveIncomingPushWithPayload:payload forType:(NSString *)type];
629-
628+
630629
// Retrieve information like handle and callerName here
631630
// NSString *uuid = /* fetch for payload or ... */ [[[NSUUID UUID] UUIDString] lowercaseString];
632631
// NSString *callerName = @"caller name here";
633632
// NSString *handle = @"caller number here";
634-
633+
635634
[RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:false localizedCallerName:callerName fromPushKit: YES];
636635

637636
completion();

android/src/main/java/io/wazo/callkeep/VoiceConnection.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ public void reportDisconnect(int reason) {
140140
case 3:
141141
setDisconnected(new DisconnectCause(DisconnectCause.BUSY));
142142
break;
143+
case 4:
144+
setDisconnected(new DisconnectCause(DisconnectCause.ANSWERED_ELSEWHERE));
145+
break;
143146
default:
144147
break;
145148
}

index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ const RNCallKeepModule = NativeModules.RNCallKeep;
66
const isIOS = Platform.OS === 'ios';
77
const supportConnectionService = !isIOS && Platform.Version >= 23;
88

9+
const CONSTANTS = {
10+
END_CALL_REASONS: {
11+
FAILED: 1,
12+
REMOTE_ENDED: 2,
13+
UNANSWERED: 3,
14+
ANSWERED_ELSEWHERE: 4,
15+
DECLINED_ELSEWHERE: 5 //only works on ios
16+
}
17+
};
18+
19+
export { CONSTANTS };
20+
921
class RNCallKeep {
1022

1123
constructor() {

ios/RNCallKeep/RNCallKeep.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,12 @@ + (void)initCallKitProvider {
245245
case CXCallEndedReasonUnanswered:
246246
[self.callKeepProvider reportCallWithUUID:uuid endedAtDate:[NSDate date] reason:CXCallEndedReasonUnanswered];
247247
break;
248+
case CXCallEndedReasonAnsweredElsewhere:
249+
[self.callKeepProvider reportCallWithUUID:uuid endedAtDate:[NSDate date] reason:CXCallEndedReasonAnsweredElsewhere];
250+
break;
251+
case CXCallEndedReasonDeclinedElsewhere:
252+
[self.callKeepProvider reportCallWithUUID:uuid endedAtDate:[NSDate date] reason:CXCallEndedReasonDeclinedElsewhere];
253+
break;
248254
default:
249255
break;
250256
}

0 commit comments

Comments
 (0)