@telnyx/react-voice-commons-sdk 0.1.3 → 0.1.5
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 +21 -0
- package/README.md +9 -23
- package/lib/callkit/callkit-coordinator.d.ts +114 -110
- package/lib/callkit/callkit-coordinator.js +706 -664
- package/lib/callkit/callkit.d.ts +41 -41
- package/lib/callkit/callkit.js +242 -252
- package/lib/callkit/index.js +47 -15
- package/lib/callkit/use-callkit.d.ts +19 -19
- package/lib/callkit/use-callkit.js +310 -270
- package/lib/context/TelnyxVoiceContext.d.ts +9 -9
- package/lib/context/TelnyxVoiceContext.js +13 -10
- package/lib/hooks/use-callkit-coordinator.d.ts +17 -9
- package/lib/hooks/use-callkit-coordinator.js +50 -45
- package/lib/hooks/useAppReadyNotifier.js +15 -13
- package/lib/hooks/useAppStateHandler.d.ts +11 -6
- package/lib/hooks/useAppStateHandler.js +110 -95
- package/lib/index.d.ts +21 -3
- package/lib/index.js +201 -50
- package/lib/internal/CallKitHandler.d.ts +6 -6
- package/lib/internal/CallKitHandler.js +104 -96
- package/lib/internal/callkit-manager.d.ts +57 -57
- package/lib/internal/callkit-manager.js +316 -299
- package/lib/internal/calls/call-state-controller.d.ts +78 -73
- package/lib/internal/calls/call-state-controller.js +326 -265
- package/lib/internal/session/session-manager.d.ts +71 -71
- package/lib/internal/session/session-manager.js +437 -360
- package/lib/internal/user-defaults-helpers.js +39 -49
- package/lib/internal/voice-pn-bridge.d.ts +112 -104
- package/lib/internal/voice-pn-bridge.js +193 -203
- package/lib/models/call-state.d.ts +46 -46
- package/lib/models/call-state.js +74 -70
- package/lib/models/call.d.ts +173 -157
- package/lib/models/call.js +492 -448
- package/lib/models/config.d.ts +18 -11
- package/lib/models/config.js +35 -37
- package/lib/models/connection-state.d.ts +10 -10
- package/lib/models/connection-state.js +16 -16
- package/lib/telnyx-voice-app.d.ts +28 -28
- package/lib/telnyx-voice-app.js +562 -459
- package/lib/telnyx-voip-client.d.ts +174 -167
- package/lib/telnyx-voip-client.js +397 -385
- package/package.json +9 -5
- package/src/telnyx-voice-app.tsx +119 -69
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# CHANGELOG.md
|
|
2
2
|
|
|
3
|
+
## [0.1.5](https://github.com/team-telnyx/react-native-voice-commons/releases/tag/0.1.5) (2025-12-08)
|
|
4
|
+
|
|
5
|
+
### Enhancement
|
|
6
|
+
|
|
7
|
+
• Updated to use @telnyx/react-native-voice-sdk@0.3.0 with advanced media events support
|
|
8
|
+
|
|
9
|
+
## [0.1.4](https://github.com/team-telnyx/react-native-voice-commons/releases/tag/0.1.4) (2025-11-25)
|
|
10
|
+
|
|
11
|
+
### Enhancement
|
|
12
|
+
|
|
13
|
+
• Enhanced 4G/WiFi reconnection mechanism for better network handling
|
|
14
|
+
• iOS version integration improvements
|
|
15
|
+
|
|
16
|
+
## [0.1.3](https://github.com/team-telnyx/react-native-voice-commons/releases/tag/0.1.3) (2025-11-20)
|
|
17
|
+
|
|
18
|
+
### Enhancement
|
|
19
|
+
|
|
20
|
+
• Fixed background answer functionality for iOS
|
|
21
|
+
• Added connecting state to Telnyx client
|
|
22
|
+
• Improved reconnection logic for Android using foreground service implementation
|
|
23
|
+
|
|
3
24
|
## [0.1.2](https://github.com/team-telnyx/react-native-voice-commons/releases/tag/0.1.2) (2025-11-04)
|
|
4
25
|
|
|
5
26
|
### Enhancement
|
package/README.md
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
# Telnyx React
|
|
1
|
+
# Telnyx React Voice Commons SDK
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A high-level, state-agnostic, drop-in module for the Telnyx React Native SDK that simplifies WebRTC voice calling integration. This library provides a comprehensive solution for building VoIP applications with native call UI support, push notifications, and seamless background handling.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
This demo app demonstrates how to integrate the `@telnyx/react-voice-commons-sdk` library to create a fully functional VoIP calling application with native call UI support, push notifications, and background handling.
|
|
8
|
-
|
|
9
|
-
### Key Features Demonstrated
|
|
5
|
+
### Key Features
|
|
10
6
|
|
|
11
7
|
- **TelnyxVoiceApp Integration**: Automatic lifecycle management and push notification handling
|
|
12
8
|
- **Native Call UI**: CallKit (iOS) and ConnectionService (Android) integration
|
|
13
9
|
- **Background Handling**: Seamless app state transitions and background call processing
|
|
14
10
|
- **Push Notifications**: Firebase (Android) and APNs (iOS) integration
|
|
15
11
|
- **Reactive State Management**: RxJS-based state streams for real-time UI updates
|
|
16
|
-
- **
|
|
17
|
-
- **
|
|
12
|
+
- **TypeScript Support**: Full TypeScript definitions for better developer experience
|
|
13
|
+
- **Cross-Platform**: Built for both iOS and Android with React Native
|
|
18
14
|
|
|
19
15
|
## About @telnyx/react-voice-commons-sdk
|
|
20
16
|
|
|
@@ -33,7 +29,7 @@ The `@telnyx/react-voice-commons-sdk` library provides:
|
|
|
33
29
|
|
|
34
30
|
### Basic Setup
|
|
35
31
|
|
|
36
|
-
|
|
32
|
+
Integrate the library using the `TelnyxVoiceApp` component for automatic lifecycle management:
|
|
37
33
|
|
|
38
34
|
```tsx
|
|
39
35
|
import { TelnyxVoiceApp, createTelnyxVoipClient } from '@telnyx/react-voice-commons-sdk';
|
|
@@ -53,7 +49,7 @@ export default function App() {
|
|
|
53
49
|
}
|
|
54
50
|
```
|
|
55
51
|
|
|
56
|
-
### Core Components
|
|
52
|
+
### Core Components
|
|
57
53
|
|
|
58
54
|
#### 1. VoIP Client Configuration
|
|
59
55
|
|
|
@@ -178,7 +174,7 @@ if (!success) {
|
|
|
178
174
|
- Network reconnection after connectivity loss
|
|
179
175
|
- App state changes (foreground/background transitions)
|
|
180
176
|
|
|
181
|
-
**Demo App Note**:
|
|
177
|
+
**Demo App Note**: When using the library in a demo application, the `TelnyxLoginForm` component may do additional storage for UI convenience (pre-filling login forms). This is separate from the library's internal authentication storage and is not required for production apps.
|
|
182
178
|
|
|
183
179
|
##### Manual Storage Management (Advanced Use Only)
|
|
184
180
|
|
|
@@ -200,7 +196,7 @@ await AsyncStorage.multiRemove([
|
|
|
200
196
|
|
|
201
197
|
### Native Integration
|
|
202
198
|
|
|
203
|
-
The
|
|
199
|
+
The library provides complete native integration for both platforms. These integrations are required for production apps using the library.
|
|
204
200
|
|
|
205
201
|
#### Android Integration
|
|
206
202
|
|
|
@@ -468,16 +464,6 @@ useEffect(() => {
|
|
|
468
464
|
|
|
469
465
|
For complete API documentation and advanced usage patterns, see the [TelnyxVoiceApp Documentation](./react-voice-commons-sdk/TELNYX_VOICE_APP.md).
|
|
470
466
|
|
|
471
|
-
## Contributing
|
|
472
|
-
|
|
473
|
-
When contributing to this demo or the underlying library:
|
|
474
|
-
|
|
475
|
-
1. Maintain compatibility with both iOS and Android platforms
|
|
476
|
-
2. Add comprehensive tests for new features
|
|
477
|
-
3. Update documentation for any API changes
|
|
478
|
-
4. Follow the existing code style and patterns
|
|
479
|
-
5. Test with both foreground and background scenarios
|
|
480
|
-
|
|
481
467
|
## License
|
|
482
468
|
|
|
483
469
|
MIT License - see LICENSE file for details.
|
|
@@ -8,116 +8,120 @@ import { TelnyxVoipClient } from '../telnyx-voip-client';
|
|
|
8
8
|
* guidelines for proper CallKit integration.
|
|
9
9
|
*/
|
|
10
10
|
declare class CallKitCoordinator {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
11
|
+
private static instance;
|
|
12
|
+
private callMap;
|
|
13
|
+
private processingCalls;
|
|
14
|
+
private endedCalls;
|
|
15
|
+
private connectedCalls;
|
|
16
|
+
private isCallFromPush;
|
|
17
|
+
private shouldAutoAnswerNextCall;
|
|
18
|
+
private voipClient;
|
|
19
|
+
static getInstance(): CallKitCoordinator;
|
|
20
|
+
private constructor();
|
|
21
|
+
private setupCallKitListeners;
|
|
22
|
+
/**
|
|
23
|
+
* Report an incoming call to CallKit (from push notification or socket)
|
|
24
|
+
* For push notifications, the call is already reported - we just need to map it
|
|
25
|
+
*/
|
|
26
|
+
reportIncomingCall(call: Call, callerName: string, callerNumber: string): Promise<string | null>;
|
|
27
|
+
/**
|
|
28
|
+
* Start an outgoing call through CallKit
|
|
29
|
+
*/
|
|
30
|
+
startOutgoingCall(
|
|
31
|
+
call: Call,
|
|
32
|
+
destinationNumber: string,
|
|
33
|
+
displayName?: string
|
|
34
|
+
): Promise<string | null>;
|
|
35
|
+
/**
|
|
36
|
+
* Answer a call from the app UI (CallKit-first approach)
|
|
37
|
+
*/
|
|
38
|
+
answerCallFromUI(call: Call): Promise<boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* End a call from the app UI (CallKit-first approach)
|
|
41
|
+
*/
|
|
42
|
+
endCallFromUI(call: Call): Promise<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* Handle CallKit answer action (triggered by CallKit)
|
|
45
|
+
*/
|
|
46
|
+
handleCallKitAnswer(callKitUUID: string, event?: any): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Handle CallKit end action (triggered by CallKit)
|
|
49
|
+
*/
|
|
50
|
+
private handleCallKitEnd;
|
|
51
|
+
/**
|
|
52
|
+
* Handle CallKit start action (triggered by CallKit for outgoing calls)
|
|
53
|
+
*/
|
|
54
|
+
private handleCallKitStart;
|
|
55
|
+
/**
|
|
56
|
+
* Handle CallKit push received event
|
|
57
|
+
* This allows us to coordinate between the push notification and any subsequent WebRTC calls
|
|
58
|
+
*/
|
|
59
|
+
handleCallKitPushReceived(callKitUUID: string, event?: any): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Handle push notification answer - when user answers from CallKit but we don't have a WebRTC call yet
|
|
62
|
+
* This is the iOS equivalent of the Android FCM handler
|
|
63
|
+
*/
|
|
64
|
+
private handlePushNotificationAnswer;
|
|
65
|
+
/**
|
|
66
|
+
* Handle push notification reject - when user rejects from CallKit but we don't have a WebRTC call yet
|
|
67
|
+
* This is the iOS equivalent of the Android FCM handler reject
|
|
68
|
+
*/
|
|
69
|
+
private handlePushNotificationReject;
|
|
70
|
+
/**
|
|
71
|
+
* Set up listeners for WebRTC call state changes
|
|
72
|
+
*/
|
|
73
|
+
private setupWebRTCCallListeners;
|
|
74
|
+
/**
|
|
75
|
+
* Clean up call mappings and listeners
|
|
76
|
+
*/
|
|
77
|
+
private cleanupCall;
|
|
78
|
+
/**
|
|
79
|
+
* Get CallKit UUID for a WebRTC call
|
|
80
|
+
*/
|
|
81
|
+
getCallKitUUID(call: Call): string | null;
|
|
82
|
+
/**
|
|
83
|
+
* Get WebRTC call for a CallKit UUID
|
|
84
|
+
*/
|
|
85
|
+
getWebRTCCall(callKitUUID: string): Call | null;
|
|
86
|
+
/**
|
|
87
|
+
* Link an existing CallKit call (from push notification) with a WebRTC call
|
|
88
|
+
* This should be called when a WebRTC call arrives that corresponds to an existing CallKit call
|
|
89
|
+
*/
|
|
90
|
+
linkExistingCallKitCall(call: Call, callKitUUID: string): void;
|
|
91
|
+
/**
|
|
92
|
+
* Set the VoIP client reference for triggering reconnection
|
|
93
|
+
*/
|
|
94
|
+
setVoipClient(voipClient: TelnyxVoipClient): void;
|
|
95
|
+
/**
|
|
96
|
+
* Helper method to clean up push notification state
|
|
97
|
+
*/
|
|
98
|
+
private cleanupPushNotificationState;
|
|
99
|
+
/**
|
|
100
|
+
* Get reference to the SDK client (for queuing actions when call doesn't exist yet)
|
|
101
|
+
*/
|
|
102
|
+
private getSDKClient;
|
|
103
|
+
/**
|
|
104
|
+
* Check if app is in background and disconnect client if no active calls
|
|
105
|
+
*/
|
|
106
|
+
private checkBackgroundDisconnection;
|
|
107
|
+
/**
|
|
108
|
+
* Reset only flags (keeping active call mappings intact)
|
|
109
|
+
*/
|
|
110
|
+
resetFlags(): void;
|
|
111
|
+
/**
|
|
112
|
+
* Check if there are any calls currently being processed by CallKit
|
|
113
|
+
* This helps prevent premature flag resets during CallKit operations
|
|
114
|
+
*/
|
|
115
|
+
hasProcessingCalls(): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Check if there's currently a call from push notification being processed
|
|
118
|
+
* This helps prevent disconnection during push call handling
|
|
119
|
+
*/
|
|
120
|
+
getIsCallFromPush(): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Check if CallKit is available and coordinator is active
|
|
123
|
+
*/
|
|
124
|
+
isAvailable(): boolean;
|
|
121
125
|
}
|
|
122
126
|
export declare const callKitCoordinator: CallKitCoordinator;
|
|
123
127
|
export default callKitCoordinator;
|