@telnyx/react-voice-commons-sdk 0.1.7-beta.0 → 0.1.7
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 +27 -0
- package/lib/callkit/callkit-coordinator.d.ts +4 -1
- package/lib/callkit/callkit-coordinator.js +4 -1
- package/lib/hooks/use-callkit-coordinator.js +5 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +7 -0
- package/lib/internal/calls/call-state-controller.js +2 -2
- package/lib/internal/session/session-manager.d.ts +3 -1
- package/lib/internal/session/session-manager.js +7 -4
- package/lib/models/call.d.ts +10 -0
- package/lib/models/call.js +14 -0
- package/lib/telnyx-voice-app.js +13 -0
- package/lib/telnyx-voip-client.d.ts +26 -2
- package/lib/telnyx-voip-client.js +49 -3
- package/package.json +1 -1
- package/src/callkit/callkit-coordinator.ts +4 -1
- package/src/hooks/use-callkit-coordinator.ts +5 -0
- package/src/index.ts +1 -0
- package/src/internal/calls/call-state-controller.ts +1 -1
- package/src/internal/session/session-manager.ts +7 -4
- package/src/models/call.ts +16 -0
- package/src/telnyx-voice-app.tsx +14 -0
- package/src/telnyx-voip-client.ts +53 -3
- package/src/types/telnyx-sdk.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# CHANGELOG.md
|
|
2
2
|
|
|
3
|
+
## [0.1.7](https://github.com/team-telnyx/react-native-voice-commons/releases/tag/0.1.7) (2026-02-20)
|
|
4
|
+
|
|
5
|
+
### Enhancement
|
|
6
|
+
|
|
7
|
+
• Added `TelnyxVoipClient.isLaunchedFromPushNotification()` static method to check if the app was cold-started from a push notification, allowing consumers to skip auto-login and avoid double-login races
|
|
8
|
+
• `createTelnyxVoipClient()` now returns a singleton — safe to call inside React component bodies without creating a new instance on every render
|
|
9
|
+
• Added `destroyTelnyxVoipClient()` to tear down the singleton when a fresh instance is needed
|
|
10
|
+
• `TelnyxVoiceApp` now automatically wires the `voipClient` on the CallKit coordinator on mount — consumers no longer need to manually call `setVoipClient()` at the correct component level
|
|
11
|
+
|
|
12
|
+
### Bug Fixing
|
|
13
|
+
|
|
14
|
+
• Fixed cold-start push notification failures caused by double-login race between user auto-login and SDK internal push login
|
|
15
|
+
• Fixed CallKit coordinator having no `voipClient` reference when user answered a call via CallKit before navigating to the correct screen
|
|
16
|
+
• Fixed `call_id` extraction in `checkForInitialPushNotification` — the double-nested path `pushData.metadata?.metadata?.call_id` never resolved, so the CallKit coordinator was bypassed on iOS
|
|
17
|
+
• Refactored `checkForInitialPushNotification` into `getAndroidPushData` and `getIOSPushData` helpers to reduce nesting and improve readability
|
|
18
|
+
|
|
19
|
+
### Deprecation
|
|
20
|
+
|
|
21
|
+
• `setVoipClient()` on `CallKitCoordinator` and `useCallKitCoordinator()` hook is now deprecated — `TelnyxVoiceApp` handles this automatically
|
|
22
|
+
|
|
23
|
+
## [0.1.7-beta.0](https://github.com/team-telnyx/react-native-voice-commons/releases/tag/0.1.7-beta.0) (2026-02-18)
|
|
24
|
+
|
|
25
|
+
### Bug Fixing
|
|
26
|
+
|
|
27
|
+
• Fixed `call_id` extraction in `checkForInitialPushNotification` — the double-nested path `pushData.metadata?.metadata?.call_id` never resolved, so the CallKit coordinator was bypassed and all iOS push calls fell through to direct handling
|
|
28
|
+
• Refactored `checkForInitialPushNotification` into `getAndroidPushData` and `getIOSPushData` helpers to reduce nesting and improve readability
|
|
29
|
+
|
|
3
30
|
## [0.1.6](https://github.com/team-telnyx/react-native-voice-commons/releases/tag/0.1.6) (2025-12-09)
|
|
4
31
|
|
|
5
32
|
### Enhancement
|
|
@@ -89,7 +89,10 @@ declare class CallKitCoordinator {
|
|
|
89
89
|
*/
|
|
90
90
|
linkExistingCallKitCall(call: Call, callKitUUID: string): void;
|
|
91
91
|
/**
|
|
92
|
-
* Set the VoIP client reference for triggering reconnection
|
|
92
|
+
* Set the VoIP client reference for triggering reconnection.
|
|
93
|
+
*
|
|
94
|
+
* @deprecated No longer needed — TelnyxVoiceApp now auto-wires the voipClient
|
|
95
|
+
* on mount. Kept for backwards compatibility.
|
|
93
96
|
*/
|
|
94
97
|
setVoipClient(voipClient: TelnyxVoipClient): void;
|
|
95
98
|
/**
|
|
@@ -673,7 +673,10 @@ class CallKitCoordinator {
|
|
|
673
673
|
this.setupWebRTCCallListeners(call, callKitUUID);
|
|
674
674
|
}
|
|
675
675
|
/**
|
|
676
|
-
* Set the VoIP client reference for triggering reconnection
|
|
676
|
+
* Set the VoIP client reference for triggering reconnection.
|
|
677
|
+
*
|
|
678
|
+
* @deprecated No longer needed — TelnyxVoiceApp now auto-wires the voipClient
|
|
679
|
+
* on mount. Kept for backwards compatibility.
|
|
677
680
|
*/
|
|
678
681
|
setVoipClient(voipClient) {
|
|
679
682
|
this.voipClient = voipClient;
|
|
@@ -36,6 +36,11 @@ function useCallKitCoordinator() {
|
|
|
36
36
|
const isAvailable = (0, react_1.useCallback)(() => {
|
|
37
37
|
return callkit_coordinator_1.default.isAvailable();
|
|
38
38
|
}, []);
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated No longer needed — TelnyxVoiceApp now auto-wires the voipClient
|
|
41
|
+
* on the CallKit coordinator when it receives the voipClient prop.
|
|
42
|
+
* This method is kept for backwards compatibility and will be removed in a future release.
|
|
43
|
+
*/
|
|
39
44
|
const setVoipClient = (0, react_1.useCallback)((voipClient) => {
|
|
40
45
|
callkit_coordinator_1.default.setVoipClient(voipClient);
|
|
41
46
|
}, []);
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -58,6 +58,7 @@ exports.useAppReadyNotifier =
|
|
|
58
58
|
exports.useAppStateHandler =
|
|
59
59
|
exports.TelnyxVoiceApp =
|
|
60
60
|
exports.createBackgroundTelnyxVoipClient =
|
|
61
|
+
exports.destroyTelnyxVoipClient =
|
|
61
62
|
exports.createTelnyxVoipClient =
|
|
62
63
|
exports.TelnyxVoipClient =
|
|
63
64
|
void 0;
|
|
@@ -75,6 +76,12 @@ Object.defineProperty(exports, 'createTelnyxVoipClient', {
|
|
|
75
76
|
return telnyx_voip_client_1.createTelnyxVoipClient;
|
|
76
77
|
},
|
|
77
78
|
});
|
|
79
|
+
Object.defineProperty(exports, 'destroyTelnyxVoipClient', {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function () {
|
|
82
|
+
return telnyx_voip_client_1.destroyTelnyxVoipClient;
|
|
83
|
+
},
|
|
84
|
+
});
|
|
78
85
|
Object.defineProperty(exports, 'createBackgroundTelnyxVoipClient', {
|
|
79
86
|
enumerable: true,
|
|
80
87
|
get: function () {
|
|
@@ -326,8 +326,8 @@ class CallStateController {
|
|
|
326
326
|
console.log('CallStateController: Reporting incoming call to CallKitCoordinator');
|
|
327
327
|
callkit_coordinator_1.callKitCoordinator.reportIncomingCall(
|
|
328
328
|
telnyxCall,
|
|
329
|
-
call.
|
|
330
|
-
call.
|
|
329
|
+
call.callerName,
|
|
330
|
+
call.callerNumber
|
|
331
331
|
);
|
|
332
332
|
} else {
|
|
333
333
|
// Handle outgoing call with CallKit
|
|
@@ -49,7 +49,9 @@ export declare class SessionManager {
|
|
|
49
49
|
*/
|
|
50
50
|
disconnect(): Promise<void>;
|
|
51
51
|
/**
|
|
52
|
-
* Disable push notifications for the current session
|
|
52
|
+
* Disable push notifications for the current session.
|
|
53
|
+
* Delegates to the TelnyxRTC client's disablePushNotification() method
|
|
54
|
+
* which sends a 'telnyx_rtc.disable_push_notification' message via the socket.
|
|
53
55
|
*/
|
|
54
56
|
disablePushNotifications(): void;
|
|
55
57
|
/**
|
|
@@ -140,16 +140,19 @@ class SessionManager {
|
|
|
140
140
|
this._connectionState.next(connection_state_1.TelnyxConnectionState.DISCONNECTED);
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
|
-
* Disable push notifications for the current session
|
|
143
|
+
* Disable push notifications for the current session.
|
|
144
|
+
* Delegates to the TelnyxRTC client's disablePushNotification() method
|
|
145
|
+
* which sends a 'telnyx_rtc.disable_push_notification' message via the socket.
|
|
144
146
|
*/
|
|
145
147
|
disablePushNotifications() {
|
|
146
148
|
if (
|
|
147
149
|
this._telnyxClient &&
|
|
148
150
|
this.currentState === connection_state_1.TelnyxConnectionState.CONNECTED
|
|
149
151
|
) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
console.log('SessionManager: Disabling push notifications for session:', this._sessionId);
|
|
153
|
+
this._telnyxClient.disablePushNotification();
|
|
154
|
+
} else {
|
|
155
|
+
console.warn('SessionManager: Cannot disable push - client not connected');
|
|
153
156
|
}
|
|
154
157
|
}
|
|
155
158
|
/**
|
package/lib/models/call.d.ts
CHANGED
|
@@ -46,6 +46,16 @@ export declare class Call {
|
|
|
46
46
|
* Whether this is an outgoing call
|
|
47
47
|
*/
|
|
48
48
|
get isOutgoing(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The original caller name (from_display_name) received in the INVITE message.
|
|
51
|
+
* Falls back to destination if not available.
|
|
52
|
+
*/
|
|
53
|
+
get callerName(): string;
|
|
54
|
+
/**
|
|
55
|
+
* The original caller number received in the INVITE message.
|
|
56
|
+
* Falls back to destination if not available.
|
|
57
|
+
*/
|
|
58
|
+
get callerNumber(): string;
|
|
49
59
|
/**
|
|
50
60
|
* Current call state (synchronous access)
|
|
51
61
|
*/
|
package/lib/models/call.js
CHANGED
|
@@ -115,6 +115,20 @@ class Call {
|
|
|
115
115
|
get isOutgoing() {
|
|
116
116
|
return !this._isIncoming;
|
|
117
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* The original caller name (from_display_name) received in the INVITE message.
|
|
120
|
+
* Falls back to destination if not available.
|
|
121
|
+
*/
|
|
122
|
+
get callerName() {
|
|
123
|
+
return this._originalCallerName || this._destination;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The original caller number received in the INVITE message.
|
|
127
|
+
* Falls back to destination if not available.
|
|
128
|
+
*/
|
|
129
|
+
get callerNumber() {
|
|
130
|
+
return this._originalCallerNumber || this._destination;
|
|
131
|
+
}
|
|
118
132
|
/**
|
|
119
133
|
* Current call state (synchronous access)
|
|
120
134
|
*/
|
package/lib/telnyx-voice-app.js
CHANGED
|
@@ -378,6 +378,19 @@ const TelnyxVoiceAppComponent = ({
|
|
|
378
378
|
});
|
|
379
379
|
return backgroundClient;
|
|
380
380
|
}, [debug, log]);
|
|
381
|
+
// Auto-wire the voipClient on the CallKit coordinator so consumers don't
|
|
382
|
+
// have to call setVoipClient() manually at the right level.
|
|
383
|
+
(0, react_1.useEffect)(() => {
|
|
384
|
+
if (react_native_1.Platform.OS === 'ios') {
|
|
385
|
+
try {
|
|
386
|
+
const { callKitCoordinator } = require('./callkit/callkit-coordinator');
|
|
387
|
+
callKitCoordinator.setVoipClient(voipClient);
|
|
388
|
+
log('Auto-wired voipClient on CallKit coordinator');
|
|
389
|
+
} catch (e) {
|
|
390
|
+
log('Error auto-wiring voipClient on CallKit coordinator:', e);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}, [voipClient, log]);
|
|
381
394
|
// Setup effect
|
|
382
395
|
(0, react_1.useEffect)(() => {
|
|
383
396
|
// Listen to connection state changes
|
|
@@ -27,6 +27,16 @@ export declare class TelnyxVoipClient {
|
|
|
27
27
|
private readonly _callStateController;
|
|
28
28
|
private readonly _options;
|
|
29
29
|
private _disposed;
|
|
30
|
+
/**
|
|
31
|
+
* Check if the app was launched from a push notification.
|
|
32
|
+
*
|
|
33
|
+
* Use this to avoid double-login on cold start. When true, the SDK will
|
|
34
|
+
* handle login internally via the push notification flow, so you should
|
|
35
|
+
* skip your normal auto-login.
|
|
36
|
+
*
|
|
37
|
+
* @returns true if there is pending push notification data indicating a push-launched app
|
|
38
|
+
*/
|
|
39
|
+
static isLaunchedFromPushNotification(): Promise<boolean>;
|
|
30
40
|
/**
|
|
31
41
|
* Creates a new TelnyxVoipClient instance.
|
|
32
42
|
*
|
|
@@ -213,11 +223,25 @@ export declare class TelnyxVoipClient {
|
|
|
213
223
|
private _throwIfDisposed;
|
|
214
224
|
}
|
|
215
225
|
/**
|
|
216
|
-
* Create
|
|
226
|
+
* Create or retrieve the shared TelnyxVoipClient instance.
|
|
227
|
+
*
|
|
228
|
+
* This uses a singleton pattern — calling it multiple times (e.g., inside a
|
|
229
|
+
* React component body) always returns the same instance. If you need to
|
|
230
|
+
* reset the instance, call `destroyTelnyxVoipClient()` first.
|
|
217
231
|
*/
|
|
218
232
|
export declare function createTelnyxVoipClient(options?: TelnyxVoipClientOptions): TelnyxVoipClient;
|
|
219
233
|
/**
|
|
220
|
-
*
|
|
234
|
+
* Destroy the shared TelnyxVoipClient instance.
|
|
235
|
+
*
|
|
236
|
+
* Disposes the current singleton so that a subsequent call to
|
|
237
|
+
* `createTelnyxVoipClient()` will create a fresh instance.
|
|
238
|
+
*/
|
|
239
|
+
export declare function destroyTelnyxVoipClient(): void;
|
|
240
|
+
/**
|
|
241
|
+
* Create a new TelnyxVoipClient instance for background push notification handling.
|
|
242
|
+
*
|
|
243
|
+
* Unlike `createTelnyxVoipClient`, this always creates a new instance because
|
|
244
|
+
* background isolates need their own independent client.
|
|
221
245
|
*/
|
|
222
246
|
export declare function createBackgroundTelnyxVoipClient(
|
|
223
247
|
options?: TelnyxVoipClientOptions
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
3
|
exports.TelnyxVoipClient = void 0;
|
|
4
4
|
exports.createTelnyxVoipClient = createTelnyxVoipClient;
|
|
5
|
+
exports.destroyTelnyxVoipClient = destroyTelnyxVoipClient;
|
|
5
6
|
exports.createBackgroundTelnyxVoipClient = createBackgroundTelnyxVoipClient;
|
|
6
7
|
const connection_state_1 = require('./models/connection-state');
|
|
7
8
|
const call_state_1 = require('./models/call-state');
|
|
8
9
|
const config_1 = require('./models/config');
|
|
9
10
|
const session_manager_1 = require('./internal/session/session-manager');
|
|
10
11
|
const call_state_controller_1 = require('./internal/calls/call-state-controller');
|
|
12
|
+
const voice_pn_bridge_1 = require('./internal/voice-pn-bridge');
|
|
11
13
|
/**
|
|
12
14
|
* The main public interface for the react-voice-commons module.
|
|
13
15
|
*
|
|
@@ -20,6 +22,26 @@ const call_state_controller_1 = require('./internal/calls/call-state-controller'
|
|
|
20
22
|
* into their chosen state management solution naturally.
|
|
21
23
|
*/
|
|
22
24
|
class TelnyxVoipClient {
|
|
25
|
+
/**
|
|
26
|
+
* Check if the app was launched from a push notification.
|
|
27
|
+
*
|
|
28
|
+
* Use this to avoid double-login on cold start. When true, the SDK will
|
|
29
|
+
* handle login internally via the push notification flow, so you should
|
|
30
|
+
* skip your normal auto-login.
|
|
31
|
+
*
|
|
32
|
+
* @returns true if there is pending push notification data indicating a push-launched app
|
|
33
|
+
*/
|
|
34
|
+
static async isLaunchedFromPushNotification() {
|
|
35
|
+
try {
|
|
36
|
+
const pendingAction = await voice_pn_bridge_1.VoicePnBridge.getPendingPushAction();
|
|
37
|
+
if (pendingAction?.action) return true;
|
|
38
|
+
const pendingVoipPush = await voice_pn_bridge_1.VoicePnBridge.getPendingVoipPush();
|
|
39
|
+
if (pendingVoipPush) return true;
|
|
40
|
+
return false;
|
|
41
|
+
} catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
23
45
|
/**
|
|
24
46
|
* Creates a new TelnyxVoipClient instance.
|
|
25
47
|
*
|
|
@@ -470,14 +492,38 @@ class TelnyxVoipClient {
|
|
|
470
492
|
}
|
|
471
493
|
exports.TelnyxVoipClient = TelnyxVoipClient;
|
|
472
494
|
// ========== Factory Functions ==========
|
|
495
|
+
let _sharedInstance = null;
|
|
473
496
|
/**
|
|
474
|
-
* Create
|
|
497
|
+
* Create or retrieve the shared TelnyxVoipClient instance.
|
|
498
|
+
*
|
|
499
|
+
* This uses a singleton pattern — calling it multiple times (e.g., inside a
|
|
500
|
+
* React component body) always returns the same instance. If you need to
|
|
501
|
+
* reset the instance, call `destroyTelnyxVoipClient()` first.
|
|
475
502
|
*/
|
|
476
503
|
function createTelnyxVoipClient(options) {
|
|
477
|
-
|
|
504
|
+
if (_sharedInstance) {
|
|
505
|
+
return _sharedInstance;
|
|
506
|
+
}
|
|
507
|
+
_sharedInstance = new TelnyxVoipClient(options);
|
|
508
|
+
return _sharedInstance;
|
|
478
509
|
}
|
|
479
510
|
/**
|
|
480
|
-
*
|
|
511
|
+
* Destroy the shared TelnyxVoipClient instance.
|
|
512
|
+
*
|
|
513
|
+
* Disposes the current singleton so that a subsequent call to
|
|
514
|
+
* `createTelnyxVoipClient()` will create a fresh instance.
|
|
515
|
+
*/
|
|
516
|
+
function destroyTelnyxVoipClient() {
|
|
517
|
+
if (_sharedInstance) {
|
|
518
|
+
_sharedInstance.dispose();
|
|
519
|
+
_sharedInstance = null;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Create a new TelnyxVoipClient instance for background push notification handling.
|
|
524
|
+
*
|
|
525
|
+
* Unlike `createTelnyxVoipClient`, this always creates a new instance because
|
|
526
|
+
* background isolates need their own independent client.
|
|
481
527
|
*/
|
|
482
528
|
function createBackgroundTelnyxVoipClient(options) {
|
|
483
529
|
return new TelnyxVoipClient(options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telnyx/react-voice-commons-sdk",
|
|
3
|
-
"version": "0.1.7
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "A high-level, state-agnostic, drop-in module for the Telnyx React Native SDK that simplifies WebRTC voice calling integration",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -740,7 +740,10 @@ class CallKitCoordinator {
|
|
|
740
740
|
}
|
|
741
741
|
|
|
742
742
|
/**
|
|
743
|
-
* Set the VoIP client reference for triggering reconnection
|
|
743
|
+
* Set the VoIP client reference for triggering reconnection.
|
|
744
|
+
*
|
|
745
|
+
* @deprecated No longer needed — TelnyxVoiceApp now auto-wires the voipClient
|
|
746
|
+
* on mount. Kept for backwards compatibility.
|
|
744
747
|
*/
|
|
745
748
|
setVoipClient(voipClient: TelnyxVoipClient): void {
|
|
746
749
|
this.voipClient = voipClient;
|
|
@@ -42,6 +42,11 @@ export function useCallKitCoordinator() {
|
|
|
42
42
|
return callKitCoordinator.isAvailable();
|
|
43
43
|
}, []);
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated No longer needed — TelnyxVoiceApp now auto-wires the voipClient
|
|
47
|
+
* on the CallKit coordinator when it receives the voipClient prop.
|
|
48
|
+
* This method is kept for backwards compatibility and will be removed in a future release.
|
|
49
|
+
*/
|
|
45
50
|
const setVoipClient = useCallback((voipClient: TelnyxVoipClient): void => {
|
|
46
51
|
callKitCoordinator.setVoipClient(voipClient);
|
|
47
52
|
}, []);
|
package/src/index.ts
CHANGED
|
@@ -392,7 +392,7 @@ export class CallStateController {
|
|
|
392
392
|
} else if (call.isIncoming) {
|
|
393
393
|
// Handle incoming call with CallKit (only if not already integrated)
|
|
394
394
|
console.log('CallStateController: Reporting incoming call to CallKitCoordinator');
|
|
395
|
-
callKitCoordinator.reportIncomingCall(telnyxCall, call.
|
|
395
|
+
callKitCoordinator.reportIncomingCall(telnyxCall, call.callerName, call.callerNumber);
|
|
396
396
|
} else {
|
|
397
397
|
// Handle outgoing call with CallKit
|
|
398
398
|
console.log('CallStateController: Starting outgoing call with CallKitCoordinator');
|
|
@@ -111,13 +111,16 @@ export class SessionManager {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
|
-
* Disable push notifications for the current session
|
|
114
|
+
* Disable push notifications for the current session.
|
|
115
|
+
* Delegates to the TelnyxRTC client's disablePushNotification() method
|
|
116
|
+
* which sends a 'telnyx_rtc.disable_push_notification' message via the socket.
|
|
115
117
|
*/
|
|
116
118
|
disablePushNotifications(): void {
|
|
117
119
|
if (this._telnyxClient && this.currentState === TelnyxConnectionState.CONNECTED) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
console.log('SessionManager: Disabling push notifications for session:', this._sessionId);
|
|
121
|
+
this._telnyxClient.disablePushNotification();
|
|
122
|
+
} else {
|
|
123
|
+
console.warn('SessionManager: Cannot disable push - client not connected');
|
|
121
124
|
}
|
|
122
125
|
}
|
|
123
126
|
|
package/src/models/call.ts
CHANGED
|
@@ -66,6 +66,22 @@ export class Call {
|
|
|
66
66
|
return !this._isIncoming;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
/**
|
|
70
|
+
* The original caller name (from_display_name) received in the INVITE message.
|
|
71
|
+
* Falls back to destination if not available.
|
|
72
|
+
*/
|
|
73
|
+
get callerName(): string {
|
|
74
|
+
return this._originalCallerName || this._destination;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The original caller number received in the INVITE message.
|
|
79
|
+
* Falls back to destination if not available.
|
|
80
|
+
*/
|
|
81
|
+
get callerNumber(): string {
|
|
82
|
+
return this._originalCallerNumber || this._destination;
|
|
83
|
+
}
|
|
84
|
+
|
|
69
85
|
/**
|
|
70
86
|
* Current call state (synchronous access)
|
|
71
87
|
*/
|
package/src/telnyx-voice-app.tsx
CHANGED
|
@@ -494,6 +494,20 @@ const TelnyxVoiceAppComponent: React.FC<TelnyxVoiceAppProps> = ({
|
|
|
494
494
|
return backgroundClient;
|
|
495
495
|
}, [debug, log]);
|
|
496
496
|
|
|
497
|
+
// Auto-wire the voipClient on the CallKit coordinator so consumers don't
|
|
498
|
+
// have to call setVoipClient() manually at the right level.
|
|
499
|
+
useEffect(() => {
|
|
500
|
+
if (Platform.OS === 'ios') {
|
|
501
|
+
try {
|
|
502
|
+
const { callKitCoordinator } = require('./callkit/callkit-coordinator');
|
|
503
|
+
callKitCoordinator.setVoipClient(voipClient);
|
|
504
|
+
log('Auto-wired voipClient on CallKit coordinator');
|
|
505
|
+
} catch (e) {
|
|
506
|
+
log('Error auto-wiring voipClient on CallKit coordinator:', e);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}, [voipClient, log]);
|
|
510
|
+
|
|
497
511
|
// Setup effect
|
|
498
512
|
useEffect(() => {
|
|
499
513
|
// Listen to connection state changes
|
|
@@ -5,6 +5,7 @@ import { TelnyxCallState } from './models/call-state';
|
|
|
5
5
|
import { Config, CredentialConfig, TokenConfig, validateConfig } from './models/config';
|
|
6
6
|
import { SessionManager } from './internal/session/session-manager';
|
|
7
7
|
import { CallStateController } from './internal/calls/call-state-controller';
|
|
8
|
+
import { VoicePnBridge } from './internal/voice-pn-bridge';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Configuration options for TelnyxVoipClient
|
|
@@ -34,6 +35,29 @@ export class TelnyxVoipClient {
|
|
|
34
35
|
private readonly _options: Required<TelnyxVoipClientOptions>;
|
|
35
36
|
private _disposed = false;
|
|
36
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Check if the app was launched from a push notification.
|
|
40
|
+
*
|
|
41
|
+
* Use this to avoid double-login on cold start. When true, the SDK will
|
|
42
|
+
* handle login internally via the push notification flow, so you should
|
|
43
|
+
* skip your normal auto-login.
|
|
44
|
+
*
|
|
45
|
+
* @returns true if there is pending push notification data indicating a push-launched app
|
|
46
|
+
*/
|
|
47
|
+
static async isLaunchedFromPushNotification(): Promise<boolean> {
|
|
48
|
+
try {
|
|
49
|
+
const pendingAction = await VoicePnBridge.getPendingPushAction();
|
|
50
|
+
if (pendingAction?.action) return true;
|
|
51
|
+
|
|
52
|
+
const pendingVoipPush = await VoicePnBridge.getPendingVoipPush();
|
|
53
|
+
if (pendingVoipPush) return true;
|
|
54
|
+
|
|
55
|
+
return false;
|
|
56
|
+
} catch {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
37
61
|
/**
|
|
38
62
|
* Creates a new TelnyxVoipClient instance.
|
|
39
63
|
*
|
|
@@ -565,15 +589,41 @@ export class TelnyxVoipClient {
|
|
|
565
589
|
|
|
566
590
|
// ========== Factory Functions ==========
|
|
567
591
|
|
|
592
|
+
let _sharedInstance: TelnyxVoipClient | null = null;
|
|
593
|
+
|
|
568
594
|
/**
|
|
569
|
-
* Create
|
|
595
|
+
* Create or retrieve the shared TelnyxVoipClient instance.
|
|
596
|
+
*
|
|
597
|
+
* This uses a singleton pattern — calling it multiple times (e.g., inside a
|
|
598
|
+
* React component body) always returns the same instance. If you need to
|
|
599
|
+
* reset the instance, call `destroyTelnyxVoipClient()` first.
|
|
570
600
|
*/
|
|
571
601
|
export function createTelnyxVoipClient(options?: TelnyxVoipClientOptions): TelnyxVoipClient {
|
|
572
|
-
|
|
602
|
+
if (_sharedInstance) {
|
|
603
|
+
return _sharedInstance;
|
|
604
|
+
}
|
|
605
|
+
_sharedInstance = new TelnyxVoipClient(options);
|
|
606
|
+
return _sharedInstance;
|
|
573
607
|
}
|
|
574
608
|
|
|
575
609
|
/**
|
|
576
|
-
*
|
|
610
|
+
* Destroy the shared TelnyxVoipClient instance.
|
|
611
|
+
*
|
|
612
|
+
* Disposes the current singleton so that a subsequent call to
|
|
613
|
+
* `createTelnyxVoipClient()` will create a fresh instance.
|
|
614
|
+
*/
|
|
615
|
+
export function destroyTelnyxVoipClient(): void {
|
|
616
|
+
if (_sharedInstance) {
|
|
617
|
+
_sharedInstance.dispose();
|
|
618
|
+
_sharedInstance = null;
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Create a new TelnyxVoipClient instance for background push notification handling.
|
|
624
|
+
*
|
|
625
|
+
* Unlike `createTelnyxVoipClient`, this always creates a new instance because
|
|
626
|
+
* background isolates need their own independent client.
|
|
577
627
|
*/
|
|
578
628
|
export function createBackgroundTelnyxVoipClient(
|
|
579
629
|
options?: TelnyxVoipClientOptions
|
|
@@ -83,6 +83,7 @@ declare module '@telnyx/react-native-voice-sdk' {
|
|
|
83
83
|
connect(): Promise<void>;
|
|
84
84
|
disconnect(): void;
|
|
85
85
|
newCall(options: CallOptions): Promise<Call>;
|
|
86
|
+
disablePushNotification(): void;
|
|
86
87
|
|
|
87
88
|
on(event: string, listener: (...args: any[]) => void): this;
|
|
88
89
|
off(event: string, listener: (...args: any[]) => void): this;
|