@telnyx/react-voice-commons-sdk 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +28 -7
- package/android/src/main/java/com/telnyx/react_voice_commons/CallForegroundService.kt +16 -2
- package/android/src/main/java/com/telnyx/react_voice_commons/TelnyxNotificationHelper.kt +345 -24
- package/android/src/main/java/com/telnyx/react_voice_commons/VoicePnBridgeModule.kt +19 -0
- package/android/src/main/java/com/telnyx/react_voice_commons/VoicePnManager.kt +19 -0
- package/ios/CallKitBridge.m +27 -1
- package/ios/CallKitBridge.swift +640 -125
- package/ios/README.md +2 -2
- package/ios/VoicePnBridge.m +6 -0
- package/ios/VoicePnBridge.swift +15 -0
- package/lib/callkit/callkit-coordinator.d.ts +39 -3
- package/lib/callkit/callkit-coordinator.js +561 -148
- package/lib/callkit/callkit.d.ts +7 -0
- package/lib/callkit/callkit.js +83 -11
- package/lib/hooks/useAppStateHandler.js +6 -2
- package/lib/internal/CallKitHandler.d.ts +3 -0
- package/lib/internal/CallKitHandler.js +52 -46
- package/lib/internal/calls/call-state-controller.d.ts +33 -1
- package/lib/internal/calls/call-state-controller.js +100 -28
- package/lib/internal/session/session-manager.d.ts +15 -1
- package/lib/internal/session/session-manager.js +214 -62
- package/lib/internal/voice-pn-bridge.d.ts +18 -0
- package/lib/internal/voice-pn-bridge.js +39 -0
- package/lib/models/call.js +35 -0
- package/lib/models/config.d.ts +10 -0
- package/lib/models/config.js +2 -0
- package/lib/telnyx-voice-app.js +85 -43
- package/lib/telnyx-voip-client.d.ts +46 -5
- package/lib/telnyx-voip-client.js +238 -22
- package/package.json +7 -5
- package/src/callkit/callkit-coordinator.ts +642 -160
- package/src/callkit/callkit.ts +110 -12
- package/src/hooks/useAppStateHandler.ts +7 -2
- package/src/internal/CallKitHandler.tsx +60 -55
- package/src/internal/calls/call-state-controller.ts +112 -29
- package/src/internal/session/session-manager.ts +260 -65
- package/src/internal/voice-pn-bridge.ts +47 -0
- package/src/models/call.ts +34 -0
- package/src/models/config.ts +10 -0
- package/src/telnyx-voice-app.tsx +96 -45
- package/src/telnyx-voip-client.ts +216 -24
- package/src/types/telnyx-sdk.d.ts +2 -1
package/ios/README.md
CHANGED
|
@@ -62,7 +62,7 @@ class AppDelegate: ExpoAppDelegate, TelnyxVoiceAppDelegate {
|
|
|
62
62
|
override func customCallKitConfiguration() -> CXProviderConfiguration {
|
|
63
63
|
let configuration = CXProviderConfiguration(localizedName: "My App Voice")
|
|
64
64
|
configuration.supportsVideo = false
|
|
65
|
-
configuration.maximumCallGroups =
|
|
65
|
+
configuration.maximumCallGroups = 2
|
|
66
66
|
configuration.maximumCallsPerCallGroup = 1
|
|
67
67
|
configuration.supportedHandleTypes = [.phoneNumber, .generic]
|
|
68
68
|
configuration.includesCallsInRecents = true
|
|
@@ -113,7 +113,7 @@ class AppDelegate: ExpoAppDelegate {
|
|
|
113
113
|
private func setupCallKit() {
|
|
114
114
|
let configuration = CXProviderConfiguration(localizedName: "Voice Call")
|
|
115
115
|
configuration.supportsVideo = false
|
|
116
|
-
configuration.maximumCallGroups =
|
|
116
|
+
configuration.maximumCallGroups = 2
|
|
117
117
|
configuration.maximumCallsPerCallGroup = 1
|
|
118
118
|
configuration.supportedHandleTypes = [.phoneNumber, .generic]
|
|
119
119
|
configuration.includesCallsInRecents = true
|
package/ios/VoicePnBridge.m
CHANGED
|
@@ -22,6 +22,12 @@ RCT_EXTERN_METHOD(getPendingVoipPush:(RCTPromiseResolveBlock)resolve
|
|
|
22
22
|
RCT_EXTERN_METHOD(clearPendingVoipPush:(RCTPromiseResolveBlock)resolve
|
|
23
23
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
24
24
|
|
|
25
|
+
RCT_EXTERN_METHOD(getPendingCallKitAnswer:(RCTPromiseResolveBlock)resolve
|
|
26
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
27
|
+
|
|
28
|
+
RCT_EXTERN_METHOD(clearPendingCallKitAnswer:(RCTPromiseResolveBlock)resolve
|
|
29
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
30
|
+
|
|
25
31
|
RCT_EXTERN_METHOD(getPendingVoipAction:(RCTPromiseResolveBlock)resolve
|
|
26
32
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
27
33
|
|
package/ios/VoicePnBridge.swift
CHANGED
|
@@ -71,6 +71,21 @@ class VoicePnBridge: NSObject {
|
|
|
71
71
|
resolve(true)
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
@objc
|
|
75
|
+
func getPendingCallKitAnswer(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
76
|
+
let answer = UserDefaults.standard.string(forKey: "pending_callkit_answer")
|
|
77
|
+
NSLog("[VoicePnBridge] getPendingCallKitAnswer - answer: \(answer ?? "nil")")
|
|
78
|
+
resolve(answer)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@objc
|
|
82
|
+
func clearPendingCallKitAnswer(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
83
|
+
UserDefaults.standard.removeObject(forKey: "pending_callkit_answer")
|
|
84
|
+
UserDefaults.standard.synchronize()
|
|
85
|
+
NSLog("[VoicePnBridge] clearPendingCallKitAnswer - cleared")
|
|
86
|
+
resolve(true)
|
|
87
|
+
}
|
|
88
|
+
|
|
74
89
|
@objc
|
|
75
90
|
func getPendingVoipAction(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
76
91
|
let pending = UserDefaults.standard.string(forKey: "pending_voip_action")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Call } from '@telnyx/react-native-voice-sdk';
|
|
2
|
-
import { TelnyxVoipClient } from '../telnyx-voip-client';
|
|
2
|
+
import type { TelnyxVoipClient } from '../telnyx-voip-client';
|
|
3
3
|
/**
|
|
4
4
|
* CallKit Coordinator - Manages the proper CallKit-first flow for iOS
|
|
5
5
|
*
|
|
@@ -14,7 +14,12 @@ declare class CallKitCoordinator {
|
|
|
14
14
|
private endedCalls;
|
|
15
15
|
private connectedCalls;
|
|
16
16
|
private isCallFromPush;
|
|
17
|
-
private
|
|
17
|
+
private pendingPushCallUUIDs;
|
|
18
|
+
private selectedCallKitUUID;
|
|
19
|
+
private restoreHeldCallPromise;
|
|
20
|
+
private pendingSwap;
|
|
21
|
+
private pendingHeldRequests;
|
|
22
|
+
private autoAnswerCallUUIDs;
|
|
18
23
|
private voipClient;
|
|
19
24
|
static getInstance(): CallKitCoordinator;
|
|
20
25
|
private constructor();
|
|
@@ -36,6 +41,17 @@ declare class CallKitCoordinator {
|
|
|
36
41
|
* Answer a call from the app UI (CallKit-first approach)
|
|
37
42
|
*/
|
|
38
43
|
answerCallFromUI(call: Call): Promise<boolean>;
|
|
44
|
+
/**
|
|
45
|
+
* Change held state from app UI through CallKit, then wait for signaling and
|
|
46
|
+
* the corresponding CXSetHeldCallAction to complete.
|
|
47
|
+
*/
|
|
48
|
+
setHeldFromUI(call: Call, isOnHold: boolean): Promise<boolean>;
|
|
49
|
+
/**
|
|
50
|
+
* Swap an active call with a held call through one CallKit transaction.
|
|
51
|
+
* The promise settles only after both corresponding WebRTC state changes
|
|
52
|
+
* have completed and their CallKit actions have been fulfilled.
|
|
53
|
+
*/
|
|
54
|
+
swapCallsFromUI(activeCall: Call, heldCall: Call): Promise<boolean>;
|
|
39
55
|
/**
|
|
40
56
|
* End a call from the app UI (CallKit-first approach)
|
|
41
57
|
*/
|
|
@@ -44,6 +60,8 @@ declare class CallKitCoordinator {
|
|
|
44
60
|
* Handle CallKit answer action (triggered by CallKit)
|
|
45
61
|
*/
|
|
46
62
|
handleCallKitAnswer(callKitUUID: string, event?: any): Promise<void>;
|
|
63
|
+
/** Handle a UUID-targeted CallKit hold or resume action. */
|
|
64
|
+
handleCallKitHeld(callKitUUID: string, isOnHold: boolean): Promise<void>;
|
|
47
65
|
/**
|
|
48
66
|
* Handle CallKit end action (triggered by CallKit)
|
|
49
67
|
*/
|
|
@@ -55,8 +73,13 @@ declare class CallKitCoordinator {
|
|
|
55
73
|
/**
|
|
56
74
|
* Handle CallKit push received event
|
|
57
75
|
* This allows us to coordinate between the push notification and any subsequent WebRTC calls
|
|
76
|
+
*
|
|
77
|
+
* Returns `true` when the push was accepted and call processing was started,
|
|
78
|
+
* or `false` when the push was filtered, rejected, or otherwise ignored so
|
|
79
|
+
* that callers can clean up any foreground-push lifecycle flags they set
|
|
80
|
+
* before calling this method.
|
|
58
81
|
*/
|
|
59
|
-
handleCallKitPushReceived(callKitUUID: string, event?: any): Promise<
|
|
82
|
+
handleCallKitPushReceived(callKitUUID: string, event?: any): Promise<boolean>;
|
|
60
83
|
/**
|
|
61
84
|
* Handle push notification answer - when user answers from CallKit but we don't have a WebRTC call yet
|
|
62
85
|
* This is the iOS equivalent of the Android FCM handler
|
|
@@ -99,10 +122,23 @@ declare class CallKitCoordinator {
|
|
|
99
122
|
* Helper method to clean up push notification state
|
|
100
123
|
*/
|
|
101
124
|
private cleanupPushNotificationState;
|
|
125
|
+
private rejectUnregisteredIncomingCall;
|
|
126
|
+
private clearMatchingPendingVoipPush;
|
|
102
127
|
/**
|
|
103
128
|
* Get reference to the SDK client (for queuing actions when call doesn't exist yet)
|
|
104
129
|
*/
|
|
105
130
|
private getSDKClient;
|
|
131
|
+
private normalizeUUID;
|
|
132
|
+
private actionKey;
|
|
133
|
+
private selectCall;
|
|
134
|
+
private isSelectedCall;
|
|
135
|
+
private recordPendingSwapAction;
|
|
136
|
+
private createPendingSwap;
|
|
137
|
+
private beginSwapRollback;
|
|
138
|
+
private restoreOriginalWebRTCStates;
|
|
139
|
+
private finishPendingSwap;
|
|
140
|
+
private finishPendingHeldRequest;
|
|
141
|
+
private restoreRemainingHeldCall;
|
|
106
142
|
/**
|
|
107
143
|
* Check if app is in background and disconnect client if no active calls
|
|
108
144
|
*/
|