@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.
Files changed (43) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +9 -23
  3. package/lib/callkit/callkit-coordinator.d.ts +114 -110
  4. package/lib/callkit/callkit-coordinator.js +706 -664
  5. package/lib/callkit/callkit.d.ts +41 -41
  6. package/lib/callkit/callkit.js +242 -252
  7. package/lib/callkit/index.js +47 -15
  8. package/lib/callkit/use-callkit.d.ts +19 -19
  9. package/lib/callkit/use-callkit.js +310 -270
  10. package/lib/context/TelnyxVoiceContext.d.ts +9 -9
  11. package/lib/context/TelnyxVoiceContext.js +13 -10
  12. package/lib/hooks/use-callkit-coordinator.d.ts +17 -9
  13. package/lib/hooks/use-callkit-coordinator.js +50 -45
  14. package/lib/hooks/useAppReadyNotifier.js +15 -13
  15. package/lib/hooks/useAppStateHandler.d.ts +11 -6
  16. package/lib/hooks/useAppStateHandler.js +110 -95
  17. package/lib/index.d.ts +21 -3
  18. package/lib/index.js +201 -50
  19. package/lib/internal/CallKitHandler.d.ts +6 -6
  20. package/lib/internal/CallKitHandler.js +104 -96
  21. package/lib/internal/callkit-manager.d.ts +57 -57
  22. package/lib/internal/callkit-manager.js +316 -299
  23. package/lib/internal/calls/call-state-controller.d.ts +78 -73
  24. package/lib/internal/calls/call-state-controller.js +326 -265
  25. package/lib/internal/session/session-manager.d.ts +71 -71
  26. package/lib/internal/session/session-manager.js +437 -360
  27. package/lib/internal/user-defaults-helpers.js +39 -49
  28. package/lib/internal/voice-pn-bridge.d.ts +112 -104
  29. package/lib/internal/voice-pn-bridge.js +193 -203
  30. package/lib/models/call-state.d.ts +46 -46
  31. package/lib/models/call-state.js +74 -70
  32. package/lib/models/call.d.ts +173 -157
  33. package/lib/models/call.js +492 -448
  34. package/lib/models/config.d.ts +18 -11
  35. package/lib/models/config.js +35 -37
  36. package/lib/models/connection-state.d.ts +10 -10
  37. package/lib/models/connection-state.js +16 -16
  38. package/lib/telnyx-voice-app.d.ts +28 -28
  39. package/lib/telnyx-voice-app.js +562 -459
  40. package/lib/telnyx-voip-client.d.ts +174 -167
  41. package/lib/telnyx-voip-client.js +397 -385
  42. package/package.json +9 -5
  43. 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 Native Voice SDK Demo
1
+ # Telnyx React Voice Commons SDK
2
2
 
3
- A comprehensive demo application showcasing the **@telnyx/react-voice-commons-sdk** library - a high-level, state-agnostic, drop-in module for the Telnyx React Native SDK that simplifies WebRTC voice calling integration.
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
- ## Overview
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
- - **Modern UI Components**: Built with NativeWind v4 and react-native-reusables
17
- - **Dark/Light Mode**: Persistent theme support with system navigation bar matching
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
- The demo shows how to integrate the library using the `TelnyxVoiceApp` component for automatic lifecycle management:
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 Used in Demo
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**: The demo app's `TelnyxLoginForm` component does additional storage for UI convenience (pre-filling the login form). This is separate from the library's internal authentication storage and is not required for production apps.
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 demo app shows complete native integration for both platforms. These integrations are required for production apps using the library.
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
- 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(call: Call, destinationNumber: string, displayName?: string): Promise<string | null>;
31
- /**
32
- * Answer a call from the app UI (CallKit-first approach)
33
- */
34
- answerCallFromUI(call: Call): Promise<boolean>;
35
- /**
36
- * End a call from the app UI (CallKit-first approach)
37
- */
38
- endCallFromUI(call: Call): Promise<boolean>;
39
- /**
40
- * Handle CallKit answer action (triggered by CallKit)
41
- */
42
- handleCallKitAnswer(callKitUUID: string, event?: any): Promise<void>;
43
- /**
44
- * Handle CallKit end action (triggered by CallKit)
45
- */
46
- private handleCallKitEnd;
47
- /**
48
- * Handle CallKit start action (triggered by CallKit for outgoing calls)
49
- */
50
- private handleCallKitStart;
51
- /**
52
- * Handle CallKit push received event
53
- * This allows us to coordinate between the push notification and any subsequent WebRTC calls
54
- */
55
- handleCallKitPushReceived(callKitUUID: string, event?: any): Promise<void>;
56
- /**
57
- * Handle push notification answer - when user answers from CallKit but we don't have a WebRTC call yet
58
- * This is the iOS equivalent of the Android FCM handler
59
- */
60
- private handlePushNotificationAnswer;
61
- /**
62
- * Handle push notification reject - when user rejects from CallKit but we don't have a WebRTC call yet
63
- * This is the iOS equivalent of the Android FCM handler reject
64
- */
65
- private handlePushNotificationReject;
66
- /**
67
- * Set up listeners for WebRTC call state changes
68
- */
69
- private setupWebRTCCallListeners;
70
- /**
71
- * Clean up call mappings and listeners
72
- */
73
- private cleanupCall;
74
- /**
75
- * Get CallKit UUID for a WebRTC call
76
- */
77
- getCallKitUUID(call: Call): string | null;
78
- /**
79
- * Get WebRTC call for a CallKit UUID
80
- */
81
- getWebRTCCall(callKitUUID: string): Call | null;
82
- /**
83
- * Link an existing CallKit call (from push notification) with a WebRTC call
84
- * This should be called when a WebRTC call arrives that corresponds to an existing CallKit call
85
- */
86
- linkExistingCallKitCall(call: Call, callKitUUID: string): void;
87
- /**
88
- * Set the VoIP client reference for triggering reconnection
89
- */
90
- setVoipClient(voipClient: TelnyxVoipClient): void;
91
- /**
92
- * Helper method to clean up push notification state
93
- */
94
- private cleanupPushNotificationState;
95
- /**
96
- * Get reference to the SDK client (for queuing actions when call doesn't exist yet)
97
- */
98
- private getSDKClient;
99
- /**
100
- * Check if app is in background and disconnect client if no active calls
101
- */
102
- private checkBackgroundDisconnection;
103
- /**
104
- * Reset only flags (keeping active call mappings intact)
105
- */
106
- resetFlags(): void;
107
- /**
108
- * Check if there are any calls currently being processed by CallKit
109
- * This helps prevent premature flag resets during CallKit operations
110
- */
111
- hasProcessingCalls(): boolean;
112
- /**
113
- * Check if there's currently a call from push notification being processed
114
- * This helps prevent disconnection during push call handling
115
- */
116
- getIsCallFromPush(): boolean;
117
- /**
118
- * Check if CallKit is available and coordinator is active
119
- */
120
- isAvailable(): boolean;
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;