@telnyx/react-voice-commons-sdk 0.1.2 → 0.1.3
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 +42 -0
- package/TelnyxVoiceCommons.podspec +31 -31
- package/ios/CallKitBridge.m +43 -43
- package/ios/CallKitBridge.swift +874 -879
- package/ios/VoicePnBridge.m +30 -30
- package/ios/VoicePnBridge.swift +86 -86
- package/lib/callkit/callkit-coordinator.d.ts +110 -117
- package/lib/callkit/callkit-coordinator.js +664 -727
- package/lib/callkit/callkit.d.ts +41 -41
- package/lib/callkit/callkit.js +252 -242
- package/lib/callkit/index.js +15 -47
- package/lib/callkit/use-callkit.d.ts +19 -19
- package/lib/callkit/use-callkit.js +270 -310
- package/lib/context/TelnyxVoiceContext.d.ts +9 -9
- package/lib/context/TelnyxVoiceContext.js +10 -13
- package/lib/hooks/use-callkit-coordinator.d.ts +9 -17
- package/lib/hooks/use-callkit-coordinator.js +45 -50
- package/lib/hooks/useAppReadyNotifier.js +13 -15
- package/lib/hooks/useAppStateHandler.d.ts +6 -11
- package/lib/hooks/useAppStateHandler.js +95 -110
- package/lib/hooks/useNetworkStateHandler.d.ts +0 -0
- package/lib/hooks/useNetworkStateHandler.js +0 -0
- package/lib/index.d.ts +3 -21
- package/lib/index.js +50 -201
- package/lib/internal/CallKitHandler.d.ts +6 -6
- package/lib/internal/CallKitHandler.js +96 -104
- package/lib/internal/callkit-manager.d.ts +57 -57
- package/lib/internal/callkit-manager.js +299 -316
- package/lib/internal/calls/call-state-controller.d.ts +73 -86
- package/lib/internal/calls/call-state-controller.js +263 -307
- package/lib/internal/session/session-manager.d.ts +71 -75
- package/lib/internal/session/session-manager.js +360 -424
- package/lib/internal/user-defaults-helpers.js +49 -39
- package/lib/internal/voice-pn-bridge.d.ts +114 -12
- package/lib/internal/voice-pn-bridge.js +212 -5
- package/lib/models/call-state.d.ts +46 -44
- package/lib/models/call-state.js +70 -68
- package/lib/models/call.d.ts +161 -133
- package/lib/models/call.js +454 -382
- package/lib/models/config.d.ts +11 -18
- package/lib/models/config.js +37 -35
- 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 +463 -481
- package/lib/telnyx-voip-client.d.ts +167 -167
- package/lib/telnyx-voip-client.js +385 -390
- package/package.json +11 -4
- package/src/callkit/callkit-coordinator.ts +18 -34
- package/src/hooks/useNetworkStateHandler.ts +0 -0
- package/src/internal/calls/call-state-controller.ts +81 -58
- package/src/internal/session/session-manager.ts +42 -26
- package/src/internal/voice-pn-bridge.ts +250 -2
- package/src/models/call-state.ts +8 -1
- package/src/models/call.ts +119 -5
- package/src/telnyx-voice-app.tsx +87 -40
- package/src/telnyx-voip-client.ts +15 -3
- package/src/types/telnyx-sdk.d.ts +16 -2
|
@@ -1,59 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getVoipToken = getVoipToken;
|
|
4
4
|
exports.getPendingVoipPush = getPendingVoipPush;
|
|
5
5
|
exports.clearPendingVoipPush = clearPendingVoipPush;
|
|
6
6
|
exports.getPendingVoipAction = getPendingVoipAction;
|
|
7
7
|
exports.clearPendingVoipAction = clearPendingVoipAction;
|
|
8
|
-
const voice_pn_bridge_1 = require(
|
|
9
|
-
const react_native_1 = require(
|
|
8
|
+
const voice_pn_bridge_1 = require("./voice-pn-bridge");
|
|
9
|
+
const react_native_1 = require("react-native");
|
|
10
10
|
/**
|
|
11
11
|
* Helper functions that use VoicePnBridge for UserDefaults functionality on iOS
|
|
12
12
|
* These functions provide the same interface as the UserDefaultsModule from main branch
|
|
13
13
|
* but route through the VoicePnBridge instead
|
|
14
14
|
*/
|
|
15
15
|
async function getVoipToken() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
if (react_native_1.Platform.OS !== 'ios')
|
|
17
|
+
return null;
|
|
18
|
+
try {
|
|
19
|
+
return await voice_pn_bridge_1.VoicePnBridge.getVoipToken();
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.warn('[UserDefaults] getVoipToken error:', error);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
23
25
|
}
|
|
24
26
|
async function getPendingVoipPush() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
if (react_native_1.Platform.OS !== 'ios')
|
|
28
|
+
return null;
|
|
29
|
+
try {
|
|
30
|
+
return await voice_pn_bridge_1.VoicePnBridge.getPendingVoipPush();
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.warn('[UserDefaults] getPendingVoipPush error:', error);
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
32
36
|
}
|
|
33
37
|
async function clearPendingVoipPush() {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
if (react_native_1.Platform.OS !== 'ios')
|
|
39
|
+
return true;
|
|
40
|
+
try {
|
|
41
|
+
return await voice_pn_bridge_1.VoicePnBridge.clearPendingVoipPush();
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.warn('[UserDefaults] clearPendingVoipPush error:', error);
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
41
47
|
}
|
|
42
48
|
async function getPendingVoipAction() {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
if (react_native_1.Platform.OS !== 'ios')
|
|
50
|
+
return null;
|
|
51
|
+
try {
|
|
52
|
+
return await voice_pn_bridge_1.VoicePnBridge.getPendingVoipAction();
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
console.warn('[UserDefaults] getPendingVoipAction error:', error);
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
50
58
|
}
|
|
51
59
|
async function clearPendingVoipAction() {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
if (react_native_1.Platform.OS !== 'ios')
|
|
61
|
+
return true;
|
|
62
|
+
try {
|
|
63
|
+
return await voice_pn_bridge_1.VoicePnBridge.clearPendingVoipAction();
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
console.warn('[UserDefaults] clearPendingVoipAction error:', error);
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
59
69
|
}
|
|
@@ -1,14 +1,116 @@
|
|
|
1
|
+
import { EmitterSubscription } from 'react-native';
|
|
2
|
+
export interface CallActionEvent {
|
|
3
|
+
action: string;
|
|
4
|
+
callId?: string;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
}
|
|
1
7
|
export interface VoicePnBridgeInterface {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
getPendingPushAction(): Promise<{
|
|
9
|
+
action: string | null;
|
|
10
|
+
metadata: string | null;
|
|
11
|
+
}>;
|
|
12
|
+
setPendingPushAction(action: string, metadata: string): Promise<boolean>;
|
|
13
|
+
clearPendingPushAction(): Promise<boolean>;
|
|
14
|
+
getPendingCallAction(): Promise<{
|
|
15
|
+
action: string | null;
|
|
16
|
+
callId: string | null;
|
|
17
|
+
timestamp: number | null;
|
|
18
|
+
}>;
|
|
19
|
+
clearPendingCallAction(): Promise<boolean>;
|
|
20
|
+
endCall(callId: string | null): Promise<boolean>;
|
|
21
|
+
showOngoingCallNotification(callerName: string | null, callerNumber: string | null, callId: string | null): Promise<boolean>;
|
|
22
|
+
hideOngoingCallNotification(): Promise<boolean>;
|
|
23
|
+
hideIncomingCallNotification(): Promise<boolean>;
|
|
24
|
+
getVoipToken(): Promise<string | null>;
|
|
25
|
+
getPendingVoipPush(): Promise<string | null>;
|
|
26
|
+
clearPendingVoipPush(): Promise<boolean>;
|
|
27
|
+
getPendingVoipAction(): Promise<string | null>;
|
|
28
|
+
clearPendingVoipAction(): Promise<boolean>;
|
|
29
|
+
}
|
|
30
|
+
declare const NativeBridge: VoicePnBridgeInterface;
|
|
31
|
+
/**
|
|
32
|
+
* Enhanced VoicePnBridge with call control and event handling capabilities
|
|
33
|
+
*/
|
|
34
|
+
export declare class VoicePnBridge {
|
|
35
|
+
/**
|
|
36
|
+
* Get any pending push notification action from native side
|
|
37
|
+
*/
|
|
38
|
+
static getPendingPushAction(): Promise<{
|
|
39
|
+
action?: string;
|
|
40
|
+
metadata?: string;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Set a pending push notification action to native side
|
|
44
|
+
*/
|
|
45
|
+
static setPendingPushAction(action: string, metadata: string): Promise<boolean>;
|
|
46
|
+
/**
|
|
47
|
+
* Get any pending call action from native side (reliable polling pattern)
|
|
48
|
+
*/
|
|
49
|
+
static getPendingCallAction(): Promise<{
|
|
50
|
+
action?: string;
|
|
51
|
+
callId?: string;
|
|
52
|
+
timestamp?: number;
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* Clear any pending call action
|
|
56
|
+
*/
|
|
57
|
+
static clearPendingCallAction(): Promise<boolean>;
|
|
58
|
+
/**
|
|
59
|
+
* Clear any pending push notification action
|
|
60
|
+
*/
|
|
61
|
+
static clearPendingPushAction(): Promise<boolean>;
|
|
62
|
+
/**
|
|
63
|
+
* React Native → Android: End/hang up the current call
|
|
64
|
+
* This will hide the ongoing call notification and notify the native side
|
|
65
|
+
*/
|
|
66
|
+
static endCall(callId?: string): Promise<boolean>;
|
|
67
|
+
/**
|
|
68
|
+
* React Native → Android: Show ongoing call notification to keep app alive
|
|
69
|
+
* Should be called when a call becomes active to prevent background termination
|
|
70
|
+
*/
|
|
71
|
+
static showOngoingCallNotification(callerName?: string, callerNumber?: string, callId?: string): Promise<boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* React Native → Android: Hide ongoing call notification
|
|
74
|
+
* Should be called when a call ends to clean up notifications
|
|
75
|
+
*/
|
|
76
|
+
static hideOngoingCallNotification(): Promise<boolean>;
|
|
77
|
+
/**
|
|
78
|
+
* React Native → Android: Hide incoming call notification
|
|
79
|
+
* Useful for dismissing notifications when call is answered/rejected in app
|
|
80
|
+
*/
|
|
81
|
+
static hideIncomingCallNotification(): Promise<boolean>;
|
|
82
|
+
/**
|
|
83
|
+
* Get VoIP token from native storage
|
|
84
|
+
*/
|
|
85
|
+
static getVoipToken(): Promise<string | null>;
|
|
86
|
+
/**
|
|
87
|
+
* Get pending VoIP push from native storage
|
|
88
|
+
*/
|
|
89
|
+
static getPendingVoipPush(): Promise<string | null>;
|
|
90
|
+
/**
|
|
91
|
+
* Clear pending VoIP push from native storage
|
|
92
|
+
*/
|
|
93
|
+
static clearPendingVoipPush(): Promise<boolean>;
|
|
94
|
+
/**
|
|
95
|
+
* Get pending VoIP action from native storage
|
|
96
|
+
*/
|
|
97
|
+
static getPendingVoipAction(): Promise<string | null>;
|
|
98
|
+
/**
|
|
99
|
+
* Clear pending VoIP action from native storage
|
|
100
|
+
*/
|
|
101
|
+
static clearPendingVoipAction(): Promise<boolean>;
|
|
102
|
+
/**
|
|
103
|
+
* Android → React Native: Listen for immediate call action events from notification buttons
|
|
104
|
+
* Use this for active calls where immediate response is needed (e.g., ending ongoing calls)
|
|
105
|
+
*/
|
|
106
|
+
static addCallActionListener(listener: (event: CallActionEvent) => void): EmitterSubscription;
|
|
107
|
+
/**
|
|
108
|
+
* Remove call action listener
|
|
109
|
+
*/
|
|
110
|
+
static removeCallActionListener(subscription: EmitterSubscription): void;
|
|
111
|
+
/**
|
|
112
|
+
* Remove all call action listeners
|
|
113
|
+
*/
|
|
114
|
+
static removeAllCallActionListeners(): void;
|
|
13
115
|
}
|
|
14
|
-
export
|
|
116
|
+
export { NativeBridge as VoicePnBridgeNative };
|
|
@@ -1,5 +1,212 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.VoicePnBridge = void 0;
|
|
4
|
-
const react_native_1 = require(
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VoicePnBridgeNative = exports.VoicePnBridge = void 0;
|
|
4
|
+
const react_native_1 = require("react-native");
|
|
5
|
+
const NativeBridge = react_native_1.NativeModules.VoicePnBridge;
|
|
6
|
+
exports.VoicePnBridgeNative = NativeBridge;
|
|
7
|
+
/**
|
|
8
|
+
* Enhanced VoicePnBridge with call control and event handling capabilities
|
|
9
|
+
*/
|
|
10
|
+
class VoicePnBridge {
|
|
11
|
+
/**
|
|
12
|
+
* Get any pending push notification action from native side
|
|
13
|
+
*/
|
|
14
|
+
static async getPendingPushAction() {
|
|
15
|
+
try {
|
|
16
|
+
const result = await NativeBridge.getPendingPushAction();
|
|
17
|
+
return {
|
|
18
|
+
action: result?.action || undefined,
|
|
19
|
+
metadata: result?.metadata || undefined,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
console.error('VoicePnBridge: Error getting pending push action:', error);
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Set a pending push notification action to native side
|
|
29
|
+
*/
|
|
30
|
+
static async setPendingPushAction(action, metadata) {
|
|
31
|
+
try {
|
|
32
|
+
return await NativeBridge.setPendingPushAction(action, metadata);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.error('VoicePnBridge: Error setting pending push action:', error);
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get any pending call action from native side (reliable polling pattern)
|
|
41
|
+
*/
|
|
42
|
+
static async getPendingCallAction() {
|
|
43
|
+
try {
|
|
44
|
+
const result = await NativeBridge.getPendingCallAction();
|
|
45
|
+
return {
|
|
46
|
+
action: result?.action || undefined,
|
|
47
|
+
callId: result?.callId || undefined,
|
|
48
|
+
timestamp: result?.timestamp || undefined,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error('VoicePnBridge: Error getting pending call action:', error);
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Clear any pending call action
|
|
58
|
+
*/
|
|
59
|
+
static async clearPendingCallAction() {
|
|
60
|
+
try {
|
|
61
|
+
return await NativeBridge.clearPendingCallAction();
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
console.error('VoicePnBridge: Error clearing pending call action:', error);
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Clear any pending push notification action
|
|
70
|
+
*/
|
|
71
|
+
static async clearPendingPushAction() {
|
|
72
|
+
try {
|
|
73
|
+
return await NativeBridge.clearPendingPushAction();
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error('VoicePnBridge: Error clearing pending push action:', error);
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* React Native → Android: End/hang up the current call
|
|
82
|
+
* This will hide the ongoing call notification and notify the native side
|
|
83
|
+
*/
|
|
84
|
+
static async endCall(callId) {
|
|
85
|
+
try {
|
|
86
|
+
return await NativeBridge.endCall(callId || null);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
console.error('VoicePnBridge: Error ending call:', error);
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* React Native → Android: Show ongoing call notification to keep app alive
|
|
95
|
+
* Should be called when a call becomes active to prevent background termination
|
|
96
|
+
*/
|
|
97
|
+
static async showOngoingCallNotification(callerName, callerNumber, callId) {
|
|
98
|
+
try {
|
|
99
|
+
return await NativeBridge.showOngoingCallNotification(callerName || null, callerNumber || null, callId || null);
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
console.error('VoicePnBridge: Error showing ongoing call notification:', error);
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* React Native → Android: Hide ongoing call notification
|
|
108
|
+
* Should be called when a call ends to clean up notifications
|
|
109
|
+
*/
|
|
110
|
+
static async hideOngoingCallNotification() {
|
|
111
|
+
try {
|
|
112
|
+
return await NativeBridge.hideOngoingCallNotification();
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
console.error('VoicePnBridge: Error hiding ongoing call notification:', error);
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* React Native → Android: Hide incoming call notification
|
|
121
|
+
* Useful for dismissing notifications when call is answered/rejected in app
|
|
122
|
+
*/
|
|
123
|
+
static async hideIncomingCallNotification() {
|
|
124
|
+
try {
|
|
125
|
+
return await NativeBridge.hideIncomingCallNotification();
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
console.error('VoicePnBridge: Error hiding incoming call notification:', error);
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get VoIP token from native storage
|
|
134
|
+
*/
|
|
135
|
+
static async getVoipToken() {
|
|
136
|
+
try {
|
|
137
|
+
return await NativeBridge.getVoipToken();
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
console.error('VoicePnBridge: Error getting VoIP token:', error);
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get pending VoIP push from native storage
|
|
146
|
+
*/
|
|
147
|
+
static async getPendingVoipPush() {
|
|
148
|
+
try {
|
|
149
|
+
return await NativeBridge.getPendingVoipPush();
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
console.error('VoicePnBridge: Error getting pending VoIP push:', error);
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Clear pending VoIP push from native storage
|
|
158
|
+
*/
|
|
159
|
+
static async clearPendingVoipPush() {
|
|
160
|
+
try {
|
|
161
|
+
return await NativeBridge.clearPendingVoipPush();
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
console.error('VoicePnBridge: Error clearing pending VoIP push:', error);
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Get pending VoIP action from native storage
|
|
170
|
+
*/
|
|
171
|
+
static async getPendingVoipAction() {
|
|
172
|
+
try {
|
|
173
|
+
return await NativeBridge.getPendingVoipAction();
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
console.error('VoicePnBridge: Error getting pending VoIP action:', error);
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Clear pending VoIP action from native storage
|
|
182
|
+
*/
|
|
183
|
+
static async clearPendingVoipAction() {
|
|
184
|
+
try {
|
|
185
|
+
return await NativeBridge.clearPendingVoipAction();
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
console.error('VoicePnBridge: Error clearing pending VoIP action:', error);
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Android → React Native: Listen for immediate call action events from notification buttons
|
|
194
|
+
* Use this for active calls where immediate response is needed (e.g., ending ongoing calls)
|
|
195
|
+
*/
|
|
196
|
+
static addCallActionListener(listener) {
|
|
197
|
+
return react_native_1.DeviceEventEmitter.addListener('TelnyxCallAction', listener);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Remove call action listener
|
|
201
|
+
*/
|
|
202
|
+
static removeCallActionListener(subscription) {
|
|
203
|
+
subscription.remove();
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Remove all call action listeners
|
|
207
|
+
*/
|
|
208
|
+
static removeAllCallActionListeners() {
|
|
209
|
+
react_native_1.DeviceEventEmitter.removeAllListeners('TelnyxCallAction');
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
exports.VoicePnBridge = VoicePnBridge;
|
|
@@ -5,18 +5,20 @@
|
|
|
5
5
|
* the complexity of the underlying SIP call states.
|
|
6
6
|
*/
|
|
7
7
|
export declare enum TelnyxCallState {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
/** Call is being initiated (outgoing) or received (incoming) */
|
|
9
|
+
RINGING = "RINGING",
|
|
10
|
+
/** Call is connecting after being answered (usually from push notification) */
|
|
11
|
+
CONNECTING = "CONNECTING",
|
|
12
|
+
/** Call has been answered and media is flowing */
|
|
13
|
+
ACTIVE = "ACTIVE",
|
|
14
|
+
/** Call is on hold */
|
|
15
|
+
HELD = "HELD",
|
|
16
|
+
/** Call has ended normally */
|
|
17
|
+
ENDED = "ENDED",
|
|
18
|
+
/** Call failed to connect or was rejected */
|
|
19
|
+
FAILED = "FAILED",
|
|
20
|
+
/** Call was dropped due to network issues */
|
|
21
|
+
DROPPED = "DROPPED"
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
24
|
* Type guard to check if a value is a valid TelnyxCallState
|
|
@@ -26,36 +28,36 @@ export declare function isTelnyxCallState(value: any): value is TelnyxCallState;
|
|
|
26
28
|
* Helper functions to determine what actions are available in each state
|
|
27
29
|
*/
|
|
28
30
|
export declare const CallStateHelpers: {
|
|
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
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Can the call be answered in this state?
|
|
33
|
+
*/
|
|
34
|
+
canAnswer(state: TelnyxCallState): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Can the call be hung up in this state?
|
|
37
|
+
*/
|
|
38
|
+
canHangup(state: TelnyxCallState): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Can the call be put on hold in this state?
|
|
41
|
+
*/
|
|
42
|
+
canHold(state: TelnyxCallState): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Can the call be resumed from hold in this state?
|
|
45
|
+
*/
|
|
46
|
+
canResume(state: TelnyxCallState): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Can the call be muted/unmuted in this state?
|
|
49
|
+
*/
|
|
50
|
+
canToggleMute(state: TelnyxCallState): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Is the call in a terminated state?
|
|
53
|
+
*/
|
|
54
|
+
isTerminated(state: TelnyxCallState): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Is the call in an active state (can have media)?
|
|
57
|
+
*/
|
|
58
|
+
isActive(state: TelnyxCallState): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Is the call in a connecting state (answered but not yet active)?
|
|
61
|
+
*/
|
|
62
|
+
isConnecting(state: TelnyxCallState): boolean;
|
|
61
63
|
};
|