@telnyx/react-voice-commons-sdk 0.1.2 → 0.1.4
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 +60 -0
- package/README.md +469 -483
- package/ios/CallKitBridge.swift +2 -7
- 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 +513 -480
- package/lib/telnyx-voip-client.d.ts +167 -167
- package/lib/telnyx-voip-client.js +385 -390
- package/package.json +115 -104
- package/src/callkit/callkit-coordinator.ts +830 -846
- package/src/hooks/useNetworkStateHandler.ts +0 -0
- package/src/internal/calls/call-state-controller.ts +407 -384
- package/src/internal/session/session-manager.ts +483 -467
- package/src/internal/voice-pn-bridge.ts +266 -18
- package/src/models/call-state.ts +105 -98
- package/src/models/call.ts +502 -388
- package/src/telnyx-voice-app.tsx +788 -690
- package/src/telnyx-voip-client.ts +551 -539
- package/src/types/telnyx-sdk.d.ts +93 -79
|
@@ -1,61 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
(Object.create
|
|
25
|
-
? function (o, v) {
|
|
26
|
-
Object.defineProperty(o, 'default', { enumerable: true, value: v });
|
|
27
|
-
}
|
|
28
|
-
: function (o, v) {
|
|
29
|
-
o['default'] = v;
|
|
30
|
-
});
|
|
31
|
-
var __importStar =
|
|
32
|
-
(this && this.__importStar) ||
|
|
33
|
-
(function () {
|
|
34
|
-
var ownKeys = function (o) {
|
|
35
|
-
ownKeys =
|
|
36
|
-
Object.getOwnPropertyNames ||
|
|
37
|
-
function (o) {
|
|
38
|
-
var ar = [];
|
|
39
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
40
|
-
return ar;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
41
24
|
};
|
|
42
|
-
|
|
25
|
+
return ownKeys(o);
|
|
43
26
|
};
|
|
44
27
|
return function (mod) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
__setModuleDefault(result, mod);
|
|
51
|
-
return result;
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
52
33
|
};
|
|
53
|
-
|
|
54
|
-
Object.defineProperty(exports,
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
36
|
exports.CallKitManager = void 0;
|
|
56
|
-
const react_native_1 = require(
|
|
57
|
-
const callkit_1 = __importStar(require(
|
|
58
|
-
const call_state_1 = require(
|
|
37
|
+
const react_native_1 = require("react-native");
|
|
38
|
+
const callkit_1 = __importStar(require("../callkit/callkit"));
|
|
39
|
+
const call_state_1 = require("../models/call-state");
|
|
59
40
|
/**
|
|
60
41
|
* Internal CallKit integration manager for react-voice-commons.
|
|
61
42
|
*
|
|
@@ -65,279 +46,281 @@ const call_state_1 = require('../models/call-state');
|
|
|
65
46
|
* @internal
|
|
66
47
|
*/
|
|
67
48
|
class CallKitManager {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
// if (this._isEnabled) {
|
|
84
|
-
// this._setupCallKitEventListeners();
|
|
85
|
-
// }
|
|
86
|
-
console.log(
|
|
87
|
-
'🔧 CallKitManager: Automatic CallKit integration DISABLED - using external CallKit implementations'
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Set up CallKit event listeners to handle user actions
|
|
92
|
-
*/
|
|
93
|
-
_setupCallKitEventListeners() {
|
|
94
|
-
console.log('🔧 CallKitManager: Setting up CallKit event listeners');
|
|
95
|
-
// Listen for answer actions from CallKit
|
|
96
|
-
callkit_1.default.onAnswerCall((event) => {
|
|
97
|
-
console.log('📞 CallKitManager: CallKit answer event received:', event);
|
|
98
|
-
this._handleCallKitAnswer(event.callUUID);
|
|
99
|
-
});
|
|
100
|
-
// Listen for end actions from CallKit
|
|
101
|
-
callkit_1.default.onEndCall((event) => {
|
|
102
|
-
console.log('📞 CallKitManager: CallKit end event received:', event);
|
|
103
|
-
this._handleCallKitEnd(event.callUUID);
|
|
104
|
-
});
|
|
105
|
-
console.log('🔧 CallKitManager: CallKit event listeners set up');
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Initialize CallKit integration
|
|
109
|
-
*/
|
|
110
|
-
initialize(onAnswerCall, onEndCall) {
|
|
111
|
-
if (!this._isEnabled) return;
|
|
112
|
-
try {
|
|
113
|
-
// This would need to be called from a React component context
|
|
114
|
-
// For now, we'll handle this differently in the call-state-controller
|
|
115
|
-
console.log('CallKitManager: CallKit integration initialized');
|
|
116
|
-
} catch (error) {
|
|
117
|
-
console.warn('CallKitManager: Failed to initialize CallKit:', error);
|
|
118
|
-
this._isEnabled = false;
|
|
49
|
+
constructor() {
|
|
50
|
+
this._callMappings = new Map(); // Call ID -> CallKit UUID
|
|
51
|
+
this._reverseCallMappings = new Map(); // CallKit UUID -> Call ID
|
|
52
|
+
this._isEnabled = false;
|
|
53
|
+
// DISABLED: Using external CallKit implementations (useCallKit, useCallKitCoordinator)
|
|
54
|
+
this._isEnabled = false; // Disable to prevent conflicts
|
|
55
|
+
console.log('🔧 CallKitManager: Initialized');
|
|
56
|
+
console.log('🔧 CallKitManager: Platform.OS =', react_native_1.Platform.OS);
|
|
57
|
+
console.log('🔧 CallKitManager: CallKit.isAvailable() =', callkit_1.default.isAvailable());
|
|
58
|
+
console.log('🔧 CallKitManager: _isEnabled =', this._isEnabled, '(DISABLED to use external CallKit)');
|
|
59
|
+
// DISABLED: Conflicts with external CallKit implementations (useCallKit, useCallKitCoordinator)
|
|
60
|
+
// if (this._isEnabled) {
|
|
61
|
+
// this._setupCallKitEventListeners();
|
|
62
|
+
// }
|
|
63
|
+
console.log('🔧 CallKitManager: Automatic CallKit integration DISABLED - using external CallKit implementations');
|
|
119
64
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Set up CallKit event listeners to handle user actions
|
|
67
|
+
*/
|
|
68
|
+
_setupCallKitEventListeners() {
|
|
69
|
+
console.log('🔧 CallKitManager: Setting up CallKit event listeners');
|
|
70
|
+
// Listen for answer actions from CallKit
|
|
71
|
+
callkit_1.default.onAnswerCall((event) => {
|
|
72
|
+
console.log('📞 CallKitManager: CallKit answer event received:', event);
|
|
73
|
+
this._handleCallKitAnswer(event.callUUID);
|
|
74
|
+
});
|
|
75
|
+
// Listen for end actions from CallKit
|
|
76
|
+
callkit_1.default.onEndCall((event) => {
|
|
77
|
+
console.log('📞 CallKitManager: CallKit end event received:', event);
|
|
78
|
+
this._handleCallKitEnd(event.callUUID);
|
|
79
|
+
});
|
|
80
|
+
console.log('🔧 CallKitManager: CallKit event listeners set up');
|
|
133
81
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
return callKitUUID;
|
|
150
|
-
} else {
|
|
151
|
-
console.log('� CallKitManager: Native CallKit.startOutgoingCall FAILED');
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
} catch (error) {
|
|
155
|
-
console.error('🔴 CallKitManager: Failed to start outgoing call:', error);
|
|
156
|
-
return null;
|
|
82
|
+
/**
|
|
83
|
+
* Initialize CallKit integration
|
|
84
|
+
*/
|
|
85
|
+
initialize(onAnswerCall, onEndCall) {
|
|
86
|
+
if (!this._isEnabled)
|
|
87
|
+
return;
|
|
88
|
+
try {
|
|
89
|
+
// This would need to be called from a React component context
|
|
90
|
+
// For now, we'll handle this differently in the call-state-controller
|
|
91
|
+
console.log('CallKitManager: CallKit integration initialized');
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
console.warn('CallKitManager: Failed to initialize CallKit:', error);
|
|
95
|
+
this._isEnabled = false;
|
|
96
|
+
}
|
|
157
97
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Handle outgoing call - start CallKit session
|
|
100
|
+
*/
|
|
101
|
+
async handleOutgoingCall(call) {
|
|
102
|
+
console.log('🔵 CallKitManager.handleOutgoingCall() CALLED');
|
|
103
|
+
console.log('🔵 CallKitManager: call.callId =', call.callId);
|
|
104
|
+
console.log('🔵 CallKitManager: call.destination =', call.destination);
|
|
105
|
+
console.log('🔵 CallKitManager: call.isIncoming =', call.isIncoming);
|
|
106
|
+
console.log('🔵 CallKitManager: _isEnabled =', this._isEnabled);
|
|
107
|
+
if (!this._isEnabled) {
|
|
108
|
+
console.log('🔴 CallKitManager: CallKit NOT ENABLED - skipping outgoing call');
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
console.log('🔵 CallKitManager: Starting CallKit session for outgoing call:', call.callId);
|
|
113
|
+
const callKitUUID = callkit_1.default.generateCallUUID();
|
|
114
|
+
console.log('🔵 CallKitManager: Generated CallKit UUID:', callKitUUID);
|
|
115
|
+
// Call the native CallKit bridge
|
|
116
|
+
console.log('🔵 CallKitManager: Calling native CallKit.startOutgoingCall...');
|
|
117
|
+
const success = await callkit_1.default.startOutgoingCall(callKitUUID, call.destination, call.destination // Using destination as display name for now
|
|
118
|
+
);
|
|
119
|
+
if (success) {
|
|
120
|
+
console.log('� CallKitManager: Native CallKit.startOutgoingCall SUCCESS!');
|
|
121
|
+
this._callMappings.set(call.callId, callKitUUID);
|
|
122
|
+
console.log('� CallKitManager: Stored call mapping:', call.callId, '->', callKitUUID);
|
|
123
|
+
return callKitUUID;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
console.log('� CallKitManager: Native CallKit.startOutgoingCall FAILED');
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
console.error('🔴 CallKitManager: Failed to start outgoing call:', error);
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
171
134
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
135
|
+
/**
|
|
136
|
+
* Handle incoming call - show CallKit UI
|
|
137
|
+
*/
|
|
138
|
+
async handleIncomingCall(call) {
|
|
139
|
+
console.log('🟡 CallKitManager.handleIncomingCall() CALLED');
|
|
140
|
+
console.log('🟡 CallKitManager: call.callId =', call.callId);
|
|
141
|
+
console.log('🟡 CallKitManager: call.destination =', call.destination);
|
|
142
|
+
console.log('🟡 CallKitManager: call.isIncoming =', call.isIncoming);
|
|
143
|
+
console.log('🟡 CallKitManager: _isEnabled =', this._isEnabled);
|
|
144
|
+
if (!this._isEnabled) {
|
|
145
|
+
console.log('🔴 CallKitManager: CallKit NOT ENABLED - skipping incoming call');
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
console.log('🟡 CallKitManager: Showing CallKit UI for incoming call:', call.callId);
|
|
150
|
+
const callKitUUID = callkit_1.default.generateCallUUID();
|
|
151
|
+
console.log('🟡 CallKitManager: Generated CallKit UUID for incoming call:', callKitUUID);
|
|
152
|
+
// Call the native CallKit bridge
|
|
153
|
+
console.log('🟡 CallKitManager: Calling native CallKit.reportIncomingCall...');
|
|
154
|
+
// For incoming calls, the call.destination contains the caller number
|
|
155
|
+
// We should use a more descriptive name if available
|
|
156
|
+
const handle = call.destination;
|
|
157
|
+
const displayName = call.destination; // For now, use the number as display name too
|
|
158
|
+
console.log('🟡 CallKitManager: Using handle:', handle, 'displayName:', displayName);
|
|
159
|
+
const success = await callkit_1.default.reportIncomingCall(callKitUUID, handle, displayName);
|
|
160
|
+
if (success) {
|
|
161
|
+
console.log('� CallKitManager: Native CallKit.reportIncomingCall SUCCESS!');
|
|
162
|
+
this._callMappings.set(call.callId, callKitUUID);
|
|
163
|
+
console.log('� CallKitManager: Stored incoming call mapping:', call.callId, '->', callKitUUID);
|
|
164
|
+
return callKitUUID;
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
console.log('� CallKitManager: Native CallKit.reportIncomingCall FAILED');
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
console.error('🔴 CallKitManager: Failed to show incoming call:', error);
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
201
175
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
176
|
+
/**
|
|
177
|
+
* Update call state in CallKit
|
|
178
|
+
*/
|
|
179
|
+
async updateCallState(call, state) {
|
|
180
|
+
if (!this._isEnabled)
|
|
181
|
+
return;
|
|
182
|
+
const callKitUUID = this._callMappings.get(call.callId);
|
|
183
|
+
if (!callKitUUID)
|
|
184
|
+
return;
|
|
185
|
+
try {
|
|
186
|
+
console.log(`🔧 CallKitManager: Updating CallKit state for call ${call.callId} to ${state}`);
|
|
187
|
+
console.log(`🔧 CallKitManager: CallKit UUID: ${callKitUUID}`);
|
|
188
|
+
switch (state) {
|
|
189
|
+
case call_state_1.TelnyxCallState.ACTIVE:
|
|
190
|
+
console.log('🟢 CallKitManager: Reporting call connected to CallKit');
|
|
191
|
+
await callkit_1.default.reportCallConnected(callKitUUID);
|
|
192
|
+
break;
|
|
193
|
+
case call_state_1.TelnyxCallState.ENDED:
|
|
194
|
+
console.log('🔴 CallKitManager: Reporting call ended to CallKit (remote ended)');
|
|
195
|
+
await callkit_1.default.reportCallEnded(callKitUUID, callkit_1.CallEndReason.RemoteEnded);
|
|
196
|
+
this._callMappings.delete(call.callId);
|
|
197
|
+
break;
|
|
198
|
+
case call_state_1.TelnyxCallState.FAILED:
|
|
199
|
+
console.log('🔴 CallKitManager: Reporting call ended to CallKit (failed)');
|
|
200
|
+
await callkit_1.default.reportCallEnded(callKitUUID, callkit_1.CallEndReason.Failed);
|
|
201
|
+
this._callMappings.delete(call.callId);
|
|
202
|
+
break;
|
|
203
|
+
case call_state_1.TelnyxCallState.RINGING:
|
|
204
|
+
console.log('🟡 CallKitManager: Call ringing - no CallKit update needed');
|
|
205
|
+
break;
|
|
206
|
+
default:
|
|
207
|
+
console.log(`🔧 CallKitManager: Unhandled state: ${state}`);
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
console.error('🔴 CallKitManager: Failed to update call state:', error);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* End CallKit session
|
|
217
|
+
*/
|
|
218
|
+
async endCall(call) {
|
|
219
|
+
if (!this._isEnabled)
|
|
220
|
+
return;
|
|
221
|
+
const callKitUUID = this._callMappings.get(call.callId);
|
|
222
|
+
if (!callKitUUID)
|
|
223
|
+
return;
|
|
224
|
+
try {
|
|
225
|
+
console.log('🔴 CallKitManager: Ending CallKit session for call:', call.callId);
|
|
226
|
+
console.log('🔴 CallKitManager: CallKit UUID:', callKitUUID);
|
|
227
|
+
// Report call ended with user-initiated reason
|
|
228
|
+
await callkit_1.default.reportCallEnded(callKitUUID, callkit_1.CallEndReason.RemoteEnded);
|
|
229
|
+
this._callMappings.delete(call.callId);
|
|
230
|
+
console.log('🔴 CallKitManager: CallKit session ended successfully');
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
console.error('🔴 CallKitManager: Failed to end call:', error);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Handle CallKit answer action
|
|
238
|
+
*/
|
|
239
|
+
_handleCallKitAnswer(callKitUUID) {
|
|
240
|
+
console.log('📞 CallKitManager: Handling CallKit answer for UUID:', callKitUUID);
|
|
241
|
+
// Find the call ID from the CallKit UUID
|
|
242
|
+
const callId = this._reverseCallMappings.get(callKitUUID);
|
|
243
|
+
if (!callId) {
|
|
244
|
+
console.error('🔴 CallKitManager: No call found for CallKit UUID:', callKitUUID);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
console.log('📞 CallKitManager: Found call ID:', callId);
|
|
248
|
+
// Find the call object and answer it
|
|
249
|
+
if (this._callMap) {
|
|
250
|
+
const call = this._callMap.get(callId);
|
|
251
|
+
if (call) {
|
|
252
|
+
console.log('📞 CallKitManager: Answering call:', callId);
|
|
253
|
+
call.answer();
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
console.error('🔴 CallKitManager: Call object not found for ID:', callId);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
console.error('🔴 CallKitManager: Call map not available');
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Handle CallKit end action
|
|
265
|
+
*/
|
|
266
|
+
_handleCallKitEnd(callKitUUID) {
|
|
267
|
+
console.log('📞 CallKitManager: Handling CallKit end for UUID:', callKitUUID);
|
|
268
|
+
// Find the call ID from the CallKit UUID
|
|
269
|
+
const callId = this._reverseCallMappings.get(callKitUUID);
|
|
270
|
+
if (!callId) {
|
|
271
|
+
console.error('🔴 CallKitManager: No call found for CallKit UUID:', callKitUUID);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
console.log('📞 CallKitManager: Found call ID:', callId);
|
|
275
|
+
// Find the call object and hang up
|
|
276
|
+
if (this._callMap) {
|
|
277
|
+
const call = this._callMap.get(callId);
|
|
278
|
+
if (call) {
|
|
279
|
+
console.log('📞 CallKitManager: Hanging up call:', callId);
|
|
280
|
+
call.hangup();
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
console.error('🔴 CallKitManager: Call object not found for ID:', callId);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
console.error('🔴 CallKitManager: Call map not available');
|
|
288
|
+
}
|
|
237
289
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
const callKitUUID = this._callMappings.get(call.callId);
|
|
245
|
-
if (!callKitUUID) return;
|
|
246
|
-
try {
|
|
247
|
-
console.log('🔴 CallKitManager: Ending CallKit session for call:', call.callId);
|
|
248
|
-
console.log('🔴 CallKitManager: CallKit UUID:', callKitUUID);
|
|
249
|
-
// Report call ended with user-initiated reason
|
|
250
|
-
await callkit_1.default.reportCallEnded(callKitUUID, callkit_1.CallEndReason.RemoteEnded);
|
|
251
|
-
this._callMappings.delete(call.callId);
|
|
252
|
-
console.log('🔴 CallKitManager: CallKit session ended successfully');
|
|
253
|
-
} catch (error) {
|
|
254
|
-
console.error('🔴 CallKitManager: Failed to end call:', error);
|
|
290
|
+
/**
|
|
291
|
+
* Set the call map reference for handling CallKit actions
|
|
292
|
+
*/
|
|
293
|
+
setCallMap(callMap) {
|
|
294
|
+
this._callMap = callMap;
|
|
295
|
+
console.log('🔧 CallKitManager: Call map reference set');
|
|
255
296
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
console.log('📞 CallKitManager: Handling CallKit answer for UUID:', callKitUUID);
|
|
262
|
-
// Find the call ID from the CallKit UUID
|
|
263
|
-
const callId = this._reverseCallMappings.get(callKitUUID);
|
|
264
|
-
if (!callId) {
|
|
265
|
-
console.error('🔴 CallKitManager: No call found for CallKit UUID:', callKitUUID);
|
|
266
|
-
return;
|
|
297
|
+
/**
|
|
298
|
+
* Check if CallKit is available
|
|
299
|
+
*/
|
|
300
|
+
get isAvailable() {
|
|
301
|
+
return this._isEnabled;
|
|
267
302
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
console.log('📞 CallKitManager: Answering call:', callId);
|
|
274
|
-
call.answer();
|
|
275
|
-
} else {
|
|
276
|
-
console.error('🔴 CallKitManager: Call object not found for ID:', callId);
|
|
277
|
-
}
|
|
278
|
-
} else {
|
|
279
|
-
console.error('🔴 CallKitManager: Call map not available');
|
|
303
|
+
/**
|
|
304
|
+
* Get CallKit UUID for a call
|
|
305
|
+
*/
|
|
306
|
+
getCallKitUUID(callId) {
|
|
307
|
+
return this._callMappings.get(callId) || null;
|
|
280
308
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
console.error('🔴 CallKitManager: No call found for CallKit UUID:', callKitUUID);
|
|
291
|
-
return;
|
|
309
|
+
/**
|
|
310
|
+
* Generate a UUID for CallKit
|
|
311
|
+
*/
|
|
312
|
+
generateUUID() {
|
|
313
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
314
|
+
const r = (Math.random() * 16) | 0;
|
|
315
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
316
|
+
return v.toString(16);
|
|
317
|
+
});
|
|
292
318
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
console.log('📞 CallKitManager: Hanging up call:', callId);
|
|
299
|
-
call.hangup();
|
|
300
|
-
} else {
|
|
301
|
-
console.error('🔴 CallKitManager: Call object not found for ID:', callId);
|
|
302
|
-
}
|
|
303
|
-
} else {
|
|
304
|
-
console.error('🔴 CallKitManager: Call map not available');
|
|
319
|
+
/**
|
|
320
|
+
* Dispose of the CallKit manager
|
|
321
|
+
*/
|
|
322
|
+
dispose() {
|
|
323
|
+
this._callMappings.clear();
|
|
305
324
|
}
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Set the call map reference for handling CallKit actions
|
|
309
|
-
*/
|
|
310
|
-
setCallMap(callMap) {
|
|
311
|
-
this._callMap = callMap;
|
|
312
|
-
console.log('🔧 CallKitManager: Call map reference set');
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* Check if CallKit is available
|
|
316
|
-
*/
|
|
317
|
-
get isAvailable() {
|
|
318
|
-
return this._isEnabled;
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Get CallKit UUID for a call
|
|
322
|
-
*/
|
|
323
|
-
getCallKitUUID(callId) {
|
|
324
|
-
return this._callMappings.get(callId) || null;
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Generate a UUID for CallKit
|
|
328
|
-
*/
|
|
329
|
-
generateUUID() {
|
|
330
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
331
|
-
const r = (Math.random() * 16) | 0;
|
|
332
|
-
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
333
|
-
return v.toString(16);
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* Dispose of the CallKit manager
|
|
338
|
-
*/
|
|
339
|
-
dispose() {
|
|
340
|
-
this._callMappings.clear();
|
|
341
|
-
}
|
|
342
325
|
}
|
|
343
326
|
exports.CallKitManager = CallKitManager;
|