expo-callkit-telecom 0.1.0

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 (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +197 -0
  3. package/android/build.gradle +32 -0
  4. package/android/src/main/AndroidManifest.xml +33 -0
  5. package/android/src/main/java/expo/modules/callkittelecom/ExpoCallKitTelecomModule.kt +384 -0
  6. package/android/src/main/java/expo/modules/callkittelecom/IncomingCallActivity.kt +275 -0
  7. package/android/src/main/java/expo/modules/callkittelecom/events/CallEventEmitter.kt +151 -0
  8. package/android/src/main/java/expo/modules/callkittelecom/events/CallEvents.kt +59 -0
  9. package/android/src/main/java/expo/modules/callkittelecom/managers/CallAudioManager.kt +361 -0
  10. package/android/src/main/java/expo/modules/callkittelecom/managers/CallManager.kt +891 -0
  11. package/android/src/main/java/expo/modules/callkittelecom/managers/CallNotificationManager.kt +445 -0
  12. package/android/src/main/java/expo/modules/callkittelecom/managers/CaptureSessionManager.kt +27 -0
  13. package/android/src/main/java/expo/modules/callkittelecom/managers/DialtonePlayer.kt +171 -0
  14. package/android/src/main/java/expo/modules/callkittelecom/managers/FulfillRequestManager.kt +150 -0
  15. package/android/src/main/java/expo/modules/callkittelecom/managers/VoIPPushManager.kt +54 -0
  16. package/android/src/main/java/expo/modules/callkittelecom/models/CallModels.kt +269 -0
  17. package/android/src/main/java/expo/modules/callkittelecom/services/CallNotificationReceiver.kt +54 -0
  18. package/android/src/main/java/expo/modules/callkittelecom/services/ExpoCallKitTelecomMessagingService.kt +161 -0
  19. package/android/src/main/java/expo/modules/callkittelecom/store/CallStore.kt +181 -0
  20. package/android/src/main/java/expo/modules/callkittelecom/utils/CallKitTelecomLog.kt +52 -0
  21. package/android/src/main/java/expo/modules/callkittelecom/utils/PermissionUtils.kt +28 -0
  22. package/android/src/main/res/drawable/expo_callkit_telecom_bg_answer.xml +9 -0
  23. package/android/src/main/res/drawable/expo_callkit_telecom_bg_avatar.xml +5 -0
  24. package/android/src/main/res/drawable/expo_callkit_telecom_bg_decline.xml +9 -0
  25. package/android/src/main/res/drawable/expo_callkit_telecom_ic_answer.xml +9 -0
  26. package/android/src/main/res/drawable/expo_callkit_telecom_ic_decline.xml +9 -0
  27. package/android/src/main/res/drawable/expo_callkit_telecom_ic_videocam.xml +9 -0
  28. package/android/src/main/res/layout/activity_incoming_call.xml +169 -0
  29. package/app.json +8 -0
  30. package/app.plugin.js +1 -0
  31. package/build/Calls.d.ts +577 -0
  32. package/build/Calls.d.ts.map +1 -0
  33. package/build/Calls.js +715 -0
  34. package/build/Calls.js.map +1 -0
  35. package/build/Calls.types.d.ts +203 -0
  36. package/build/Calls.types.d.ts.map +1 -0
  37. package/build/Calls.types.js +2 -0
  38. package/build/Calls.types.js.map +1 -0
  39. package/build/ExpoCallKitTelecomModule.d.ts +3 -0
  40. package/build/ExpoCallKitTelecomModule.d.ts.map +1 -0
  41. package/build/ExpoCallKitTelecomModule.js +4 -0
  42. package/build/ExpoCallKitTelecomModule.js.map +1 -0
  43. package/build/hooks/index.d.ts +2 -0
  44. package/build/hooks/index.d.ts.map +1 -0
  45. package/build/hooks/index.js +2 -0
  46. package/build/hooks/index.js.map +1 -0
  47. package/build/hooks/useVoIPPushToken.d.ts +14 -0
  48. package/build/hooks/useVoIPPushToken.d.ts.map +1 -0
  49. package/build/hooks/useVoIPPushToken.js +26 -0
  50. package/build/hooks/useVoIPPushToken.js.map +1 -0
  51. package/build/index.d.ts +4 -0
  52. package/build/index.d.ts.map +1 -0
  53. package/build/index.js +4 -0
  54. package/build/index.js.map +1 -0
  55. package/expo-module.config.json +10 -0
  56. package/ios/AppDelegateSubscriber.swift +93 -0
  57. package/ios/ExpoCallKitTelecom.podspec +31 -0
  58. package/ios/ExpoCallKitTelecomLogger.swift +55 -0
  59. package/ios/ExpoCallKitTelecomModule.swift +503 -0
  60. package/ios/Managers/AudioManager.swift +363 -0
  61. package/ios/Managers/CallEventEmitter.swift +199 -0
  62. package/ios/Managers/CallManager+CXProviderDelegate.swift +195 -0
  63. package/ios/Managers/CallManager.swift +714 -0
  64. package/ios/Managers/CaptureSessionManager.swift +54 -0
  65. package/ios/Managers/DialtonePlayer.swift +126 -0
  66. package/ios/Managers/FulfillRequestManager.swift +154 -0
  67. package/ios/Managers/VoIPPushManager+PKPushRegistryDelegate.swift +123 -0
  68. package/ios/Managers/VoIPPushManager.swift +58 -0
  69. package/ios/Models/CallEvents.swift +263 -0
  70. package/ios/Models/CallOptions.swift +15 -0
  71. package/ios/Models/CallParticipant.swift +37 -0
  72. package/ios/Models/CallSession.swift +80 -0
  73. package/ios/Models/IncomingCallEvent.swift +196 -0
  74. package/ios/Stores/CallStore.swift +149 -0
  75. package/package.json +56 -0
  76. package/plugin/build/constants.d.ts +3 -0
  77. package/plugin/build/constants.js +7 -0
  78. package/plugin/build/withExpoCallKitTelecom.d.ts +67 -0
  79. package/plugin/build/withExpoCallKitTelecom.js +16 -0
  80. package/plugin/build/withExpoCallKitTelecomAndroid.d.ts +3 -0
  81. package/plugin/build/withExpoCallKitTelecomAndroid.js +177 -0
  82. package/plugin/build/withExpoCallKitTelecomIos.d.ts +3 -0
  83. package/plugin/build/withExpoCallKitTelecomIos.js +195 -0
  84. package/plugin/src/constants.ts +4 -0
  85. package/plugin/src/withExpoCallKitTelecom.ts +83 -0
  86. package/plugin/src/withExpoCallKitTelecomAndroid.ts +293 -0
  87. package/plugin/src/withExpoCallKitTelecomIos.ts +276 -0
  88. package/src/Calls.ts +848 -0
  89. package/src/Calls.types.ts +275 -0
  90. package/src/ExpoCallKitTelecomModule.ts +4 -0
  91. package/src/hooks/index.ts +1 -0
  92. package/src/hooks/useVoIPPushToken.ts +34 -0
  93. package/src/index.ts +3 -0
package/build/Calls.js ADDED
@@ -0,0 +1,715 @@
1
+ /**
2
+ * @module Calls
3
+ *
4
+ * This module provides APIs for managing VoIP calls with native system integration.
5
+ * Functions are organized into three categories:
6
+ *
7
+ * ## Requests (Imperative)
8
+ * Functions that initiate actions from the app. These request the system to perform
9
+ * an operation on behalf of the user:
10
+ * - {@link startOutgoingCall} - Start a new outgoing call
11
+ * - {@link answerCall} - Answer an incoming call
12
+ * - {@link endCall} - End or decline an active call
13
+ * - {@link setMuted} - Mute/unmute the call
14
+ * - {@link setHeld} - Hold/unhold the call
15
+ * - {@link playDTMF} - Play DTMF tones
16
+ *
17
+ * ## Reporters
18
+ * Functions that report state changes to the system. Use these to inform the system
19
+ * about events that occurred outside of its control (e.g., from your backend or
20
+ * media connection):
21
+ * - {@link reportIncomingCall} - Report a new incoming call (e.g., from push notification)
22
+ * - {@link reportOutgoingCallConnected} - Report that an outgoing call's media is connected
23
+ * - {@link reportCallEnded} - Report that a call ended externally (e.g., remote hangup)
24
+ * - {@link reportVideo} - Report video state changes
25
+ *
26
+ * ## Fulfillers
27
+ * Functions that complete pending system requests. When the system requests an action
28
+ * (via event listeners), your app must perform the action and then call the corresponding
29
+ * fulfiller to confirm completion:
30
+ * - {@link fulfillIncomingCallConnected} - Confirm that incoming call media is connected
31
+ *
32
+ * ## Typical Flow
33
+ *
34
+ * **Outgoing Call:**
35
+ * 1. Call {@link startOutgoingCall} to initiate
36
+ * 2. Listen for {@link addCallStartedListener} to know when to connect media
37
+ * 3. Connect your media (e.g., WebRTC)
38
+ * 4. Call {@link reportOutgoingCallConnected} when media is ready
39
+ *
40
+ * **Incoming Call:**
41
+ * 1. Receive push notification with call data
42
+ * 2. Call {@link reportIncomingCall} to show the incoming call UI
43
+ * 3. Listen for {@link addCallAnsweredListener} to know when user answered
44
+ * 4. Connect your media (e.g., WebRTC)
45
+ * 5. Call {@link fulfillIncomingCallConnected} when media is ready
46
+ *
47
+ * **Ending a Call:**
48
+ * - If user ends: Call {@link endCall} and clean up media
49
+ * - If remote ends: Clean up media, then call {@link reportCallEnded}
50
+ */
51
+ import { Platform } from "react-native";
52
+ import ExpoCallKitTelecomModule from "./ExpoCallKitTelecomModule";
53
+ // ============================================================================
54
+ // Call Session
55
+ // ============================================================================
56
+ /**
57
+ * Gets the currently active call session, if any.
58
+ *
59
+ * @returns The active call session, or `null` if no call is in progress.
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const session = await getActiveCallSession();
64
+ * if (session) {
65
+ * console.log('Active call with:', session.remoteParticipants[0]?.displayName);
66
+ * }
67
+ * ```
68
+ */
69
+ export async function getActiveCallSession() {
70
+ const session = await ExpoCallKitTelecomModule.getActiveCallSession();
71
+ if (session) {
72
+ }
73
+ return session;
74
+ }
75
+ /**
76
+ * Subscribes to call session added events.
77
+ *
78
+ * Fired when a new call session is created, either from an outgoing call request
79
+ * or an incoming call report.
80
+ *
81
+ * @param listener - Callback invoked when a session is added.
82
+ * @returns A subscription that can be removed by calling `.remove()`.
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * const subscription = addCallSessionAddedListener((event) => {
87
+ * console.log('New call session:', event.session.id);
88
+ * });
89
+ *
90
+ * // Later, to unsubscribe:
91
+ * subscription.remove();
92
+ * ```
93
+ */
94
+ export function addCallSessionAddedListener(listener) {
95
+ return ExpoCallKitTelecomModule.addListener("onCallSessionAdded", (event) => {
96
+ listener(event);
97
+ });
98
+ }
99
+ /**
100
+ * Subscribes to call session updated events.
101
+ *
102
+ * Fired when an existing call session's state changes (e.g., status, mute state).
103
+ *
104
+ * @param listener - Callback invoked when a session is updated.
105
+ * @returns A subscription that can be removed by calling `.remove()`.
106
+ */
107
+ export function addCallSessionUpdatedListener(listener) {
108
+ return ExpoCallKitTelecomModule.addListener("onCallSessionUpdated", (event) => {
109
+ listener(event);
110
+ });
111
+ }
112
+ /**
113
+ * Subscribes to call session removed events.
114
+ *
115
+ * Fired when a call session is removed after the call has ended and been cleaned up.
116
+ *
117
+ * @param listener - Callback invoked when a session is removed.
118
+ * @returns A subscription that can be removed by calling `.remove()`.
119
+ */
120
+ export function addCallSessionRemovedListener(listener) {
121
+ return ExpoCallKitTelecomModule.addListener("onCallSessionRemoved", listener);
122
+ }
123
+ // ============================================================================
124
+ // Audio Session
125
+ // ============================================================================
126
+ /**
127
+ * Gets the current audio session state.
128
+ *
129
+ * Returns information about the audio session including whether it's active,
130
+ * the current category/mode, and the audio route (speaker, earpiece, etc.).
131
+ *
132
+ * @returns The current audio session state.
133
+ *
134
+ * @category Audio
135
+ */
136
+ export function getAudioSession() {
137
+ return ExpoCallKitTelecomModule.getAudioSessionState();
138
+ }
139
+ /**
140
+ * Gets the current capture session state.
141
+ *
142
+ * Returns information about the capture session including camera permission status.
143
+ *
144
+ * @returns The current capture session state.
145
+ *
146
+ * @category Capture
147
+ */
148
+ export function getCaptureSession() {
149
+ return ExpoCallKitTelecomModule.getCaptureSessionState();
150
+ }
151
+ /**
152
+ * Sets the RTC audio session configuration (iOS only).
153
+ *
154
+ * This sets up WebRTC's RTCAudioSession default configuration and enables manual
155
+ * audio management. On Android this is a no-op — audio configuration is handled
156
+ * by {@link prepareAudioSessionForCall}.
157
+ *
158
+ * @param hasVideo - Whether to configure for video calls (uses speaker by default)
159
+ * or audio-only calls (uses earpiece by default).
160
+ *
161
+ * @category Audio
162
+ */
163
+ export function setRTCAudioSessionConfiguration(hasVideo) {
164
+ if (Platform.OS === "ios") {
165
+ ExpoCallKitTelecomModule.setRTCAudioSessionConfiguration(hasVideo);
166
+ }
167
+ }
168
+ /**
169
+ * Prepares the audio session for an upcoming call.
170
+ *
171
+ * This snapshots the current audio configuration (for later restoration) and
172
+ * pre-configures the audio session for the call. Called automatically when
173
+ * reporting/starting a call, but can be called manually for early preparation.
174
+ *
175
+ * @param hasVideo - Whether to configure for video calls (uses speaker by default)
176
+ * or audio-only calls (uses earpiece by default).
177
+ *
178
+ * @category Audio
179
+ */
180
+ export function prepareAudioSessionForCall(hasVideo) {
181
+ ExpoCallKitTelecomModule.prepareAudioSessionForCall(hasVideo);
182
+ }
183
+ /**
184
+ * Restores the audio session to its pre-call configuration.
185
+ *
186
+ * Call this if a call fails to start after prepareAudioSessionForCall was called,
187
+ * or to manually restore the audio session. This is called automatically when
188
+ * the audio session is deactivated after a call ends.
189
+ *
190
+ * @category Audio
191
+ */
192
+ export function restoreAudioSession() {
193
+ ExpoCallKitTelecomModule.restoreAudioSession();
194
+ }
195
+ /**
196
+ * Sets the audio session port override.
197
+ *
198
+ * Use this to route audio to the speaker instead of the earpiece, or vice versa.
199
+ *
200
+ * @param enabled - If `true`, routes audio to the speaker. If `false`, uses
201
+ * the default route (typically earpiece for voice calls).
202
+ *
203
+ * @category Audio
204
+ */
205
+ export function setAudioSessionPortOverride(enabled) {
206
+ ExpoCallKitTelecomModule.setAudioSessionPortOverride(enabled);
207
+ }
208
+ /**
209
+ * Subscribes to audio session activated events.
210
+ *
211
+ * Fired when the audio session is activated for a call. This is when your
212
+ * app gains exclusive access to audio hardware.
213
+ *
214
+ * @param listener - Callback invoked when audio session activates.
215
+ * @returns A subscription that can be removed by calling `.remove()`.
216
+ *
217
+ * @category Audio Event Listener
218
+ */
219
+ export function addAudioSessionActivatedListener(listener) {
220
+ return ExpoCallKitTelecomModule.addListener("onAudioSessionActivated", listener);
221
+ }
222
+ /**
223
+ * Subscribes to audio session deactivated events.
224
+ *
225
+ * Fired when the audio session is deactivated after a call ends.
226
+ *
227
+ * @param listener - Callback invoked when audio session deactivates.
228
+ * @returns A subscription that can be removed by calling `.remove()`.
229
+ *
230
+ * @category Audio Event Listener
231
+ */
232
+ export function addAudioSessionDeactivatedListener(listener) {
233
+ return ExpoCallKitTelecomModule.addListener("onAudioSessionDeactivated", listener);
234
+ }
235
+ /**
236
+ * Subscribes to audio route changed events.
237
+ *
238
+ * Fired when the audio route changes (e.g., user connects Bluetooth headphones,
239
+ * toggles speaker mode).
240
+ *
241
+ * @param listener - Callback invoked when audio route changes.
242
+ * @returns A subscription that can be removed by calling `.remove()`.
243
+ *
244
+ * @category Audio Event Listener
245
+ */
246
+ export function addAudioRouteChangedListener(listener) {
247
+ return ExpoCallKitTelecomModule.addListener("onAudioRouteChanged", listener);
248
+ }
249
+ // ============================================================================
250
+ // Call Intent Event Listeners
251
+ // ============================================================================
252
+ /**
253
+ * Subscribes to call intent received events.
254
+ *
255
+ * Fired when the user initiates a call from outside the app, such as tapping
256
+ * a contact in the iOS Recents list or via Siri. The event contains the handle
257
+ * (phone number/email) and whether video is requested.
258
+ *
259
+ * The app should resolve the handle to a known recipient and call
260
+ * {@link startOutgoingCall} to fulfill the intent.
261
+ *
262
+ * @param listener - Callback invoked when a call intent is received.
263
+ * @returns A subscription that can be removed by calling `.remove()`.
264
+ *
265
+ * @category Event Listener
266
+ */
267
+ export function addCallIntentReceivedListener(listener) {
268
+ return ExpoCallKitTelecomModule.addListener("onCallIntentReceived", listener);
269
+ }
270
+ // ============================================================================
271
+ // Start Outgoing Call
272
+ // ============================================================================
273
+ /**
274
+ * Starts an outgoing call to the specified recipient.
275
+ *
276
+ * This requests the system to initiate a call. The system will display the
277
+ * appropriate call UI and emit an {@link OutgoingCallStartedEvent} when you should
278
+ * begin connecting your media.
279
+ *
280
+ * @param recipient - The participant to call.
281
+ * @param options - Call configuration options (e.g., video enabled).
282
+ * @returns The unique identifier for this call session.
283
+ *
284
+ * @example
285
+ * ```typescript
286
+ * const callId = await startOutgoingCall(
287
+ * { id: 'user-123', displayName: 'John Doe' },
288
+ * { hasVideo: true }
289
+ * );
290
+ * ```
291
+ *
292
+ * @category Request
293
+ */
294
+ export async function startOutgoingCall(recipient, options) {
295
+ return await ExpoCallKitTelecomModule.startOutgoingCall(recipient, options);
296
+ }
297
+ /**
298
+ * Subscribes to outgoing call started events.
299
+ *
300
+ * Fired when an outgoing call (initiated via {@link startOutgoingCall}) has
301
+ * been accepted by the system. You should provision your media connection
302
+ * and begin connecting.
303
+ *
304
+ * @param listener - Callback invoked when an outgoing call starts.
305
+ * @returns A subscription that can be removed by calling `.remove()`.
306
+ *
307
+ * @category Event Listener
308
+ */
309
+ export function addOutgoingCallStartedListener(listener) {
310
+ return ExpoCallKitTelecomModule.addListener("onOutgoingCallStarted", listener);
311
+ }
312
+ // ============================================================================
313
+ // Report Incoming Call
314
+ // ============================================================================
315
+ /**
316
+ * Reports an incoming call to the system.
317
+ *
318
+ * Call this when you receive a push notification or other signal indicating
319
+ * an incoming call. The system will display the incoming call UI.
320
+ *
321
+ * @param event - The incoming call event containing caller information.
322
+ *
323
+ * @example
324
+ * ```typescript
325
+ * await reportIncomingCall({
326
+ * callId: '550e8400-e29b-41d4-a716-446655440000',
327
+ * caller: {
328
+ * id: 'user-456',
329
+ * displayName: 'Jane Smith',
330
+ * phoneNumber: '+1234567890',
331
+ * },
332
+ * hasVideo: false,
333
+ * startedAt: new Date(),
334
+ * });
335
+ * ```
336
+ *
337
+ * @category Reporter
338
+ */
339
+ export async function reportIncomingCall(event) {
340
+ await ExpoCallKitTelecomModule.reportIncomingCall(event);
341
+ }
342
+ /**
343
+ * Subscribes to incoming call reported events.
344
+ *
345
+ * Fired after an incoming call has been successfully reported to the system
346
+ * and the call session has been added to the store. Use this to set up
347
+ * early subscriptions (e.g., call signaling) before the call is answered.
348
+ *
349
+ * @param listener - Callback invoked when an incoming call is reported.
350
+ * @returns A subscription that can be removed by calling `.remove()`.
351
+ *
352
+ * @category Event Listener
353
+ */
354
+ export function addIncomingCallReportedListener(listener) {
355
+ return ExpoCallKitTelecomModule.addListener("onIncomingCallReported", listener);
356
+ }
357
+ // ============================================================================
358
+ // Answer Call
359
+ // ============================================================================
360
+ /**
361
+ * Answers an incoming call.
362
+ *
363
+ * Use this when the user taps an answer button in your app's custom UI.
364
+ * The system will emit a {@link CallAnsweredEvent} to confirm the answer.
365
+ *
366
+ * @param id - The call session ID to answer.
367
+ *
368
+ * @category Request
369
+ */
370
+ export async function answerCall(id) {
371
+ await ExpoCallKitTelecomModule.answerCall(id);
372
+ }
373
+ /**
374
+ * Subscribes to call answered events.
375
+ *
376
+ * Fired when the user answers an incoming call (either from the system UI or
377
+ * via {@link answerCall}). You should begin connecting your media.
378
+ *
379
+ * @param listener - Callback invoked when a call is answered.
380
+ * @returns A subscription that can be removed by calling `.remove()`.
381
+ *
382
+ * @category Event Listener
383
+ */
384
+ export function addCallAnsweredListener(listener) {
385
+ return ExpoCallKitTelecomModule.addListener("onCallAnswered", listener);
386
+ }
387
+ // ============================================================================
388
+ // Fulfill Incoming Call
389
+ // ============================================================================
390
+ /**
391
+ * Fulfills an incoming call by confirming the media connection is established.
392
+ *
393
+ * Call this after the user answers an incoming call and your media connection
394
+ * (e.g., WebRTC) is fully connected and ready for audio/video.
395
+ *
396
+ * @param requestId - The request ID from the CallAnsweredEvent.
397
+ *
398
+ * @category Fulfiller
399
+ */
400
+ export async function fulfillIncomingCallConnected(requestId) {
401
+ await ExpoCallKitTelecomModule.fulfillIncomingCallAnswered(requestId);
402
+ }
403
+ /**
404
+ * Fails a pending incoming call connection request.
405
+ *
406
+ * Call this when the answer flow fails before media is connected
407
+ * (e.g., API error). On iOS, causes CXAnswerCallAction to fail, which
408
+ * triggers CallKit to end the call via CXEndCallAction. On Android,
409
+ * ends the call via {@link reportCallEnded} which also cancels any
410
+ * pending fulfill request.
411
+ *
412
+ * @param id - The call session ID.
413
+ * @param requestId - The request ID from the CallAnsweredEvent.
414
+ *
415
+ * @category Fulfiller
416
+ */
417
+ export async function failIncomingCallConnected(id, requestId) {
418
+ if (Platform.OS === "ios") {
419
+ await ExpoCallKitTelecomModule.failIncomingCallConnected(requestId);
420
+ }
421
+ else {
422
+ await ExpoCallKitTelecomModule.reportCallEnded(id, "failed");
423
+ }
424
+ }
425
+ // ============================================================================
426
+ // Report Outgoing Call Connected
427
+ // ============================================================================
428
+ /**
429
+ * Reports that an outgoing call's media connection is established.
430
+ *
431
+ * Call this after starting an outgoing call and your media connection
432
+ * (e.g., WebRTC) is fully connected and the remote party has answered.
433
+ *
434
+ * @param id - The call session ID.
435
+ *
436
+ * @category Reporter
437
+ */
438
+ export async function reportOutgoingCallConnected(id) {
439
+ await ExpoCallKitTelecomModule.reportOutgoingCallConnected(id);
440
+ }
441
+ // ============================================================================
442
+ // End Call
443
+ // ============================================================================
444
+ /**
445
+ * Ends an active call.
446
+ *
447
+ * Requests the system to end the call. The system will emit a {@link CallEndedEvent}
448
+ * to notify that the call has ended. Clean up your media connection when you receive
449
+ * this event.
450
+ *
451
+ * @param id - The call session ID to end.
452
+ *
453
+ * @category Request
454
+ */
455
+ export async function endCall(id) {
456
+ await ExpoCallKitTelecomModule.endCall(id);
457
+ }
458
+ /**
459
+ * Subscribes to call ended events.
460
+ *
461
+ * Fired when a call has ended (e.g., user pressed end button).
462
+ * Clean up your media connection when you receive this event.
463
+ *
464
+ * @param listener - Callback invoked when a call ends.
465
+ * @returns A subscription that can be removed by calling `.remove()`.
466
+ *
467
+ * @category Event Listener
468
+ */
469
+ export function addCallEndedListener(listener) {
470
+ return ExpoCallKitTelecomModule.addListener("onCallEnded", listener);
471
+ }
472
+ /**
473
+ * Reports that a call has ended for an external reason.
474
+ *
475
+ * Use this when a call ends due to reasons outside the local user's control,
476
+ * such as: remote party hung up, network failure, call declined elsewhere, etc.
477
+ *
478
+ * @param id - The call session ID.
479
+ * @param reason - The reason the call ended.
480
+ *
481
+ * @example
482
+ * ```typescript
483
+ * // Remote party hung up
484
+ * await reportCallEnded(callId, 'remoteEnded');
485
+ *
486
+ * // Call failed due to network error
487
+ * await reportCallEnded(callId, 'failed');
488
+ * ```
489
+ *
490
+ * @category Reporter
491
+ */
492
+ export async function reportCallEnded(id, reason) {
493
+ await ExpoCallKitTelecomModule.reportCallEnded(id, reason);
494
+ }
495
+ /**
496
+ * Subscribes to reported call ended events.
497
+ *
498
+ * Fired after {@link reportCallEnded} is called, confirming the system has
499
+ * been notified of the externally-ended call.
500
+ *
501
+ * @param listener - Callback invoked when a call end is reported.
502
+ * @returns A subscription that can be removed by calling `.remove()`.
503
+ *
504
+ * @category Event Listener
505
+ */
506
+ export function addReportedCallEndedListener(listener) {
507
+ return ExpoCallKitTelecomModule.addListener("onCallReportedEnded", listener);
508
+ }
509
+ // ============================================================================
510
+ // Mute Support
511
+ // ============================================================================
512
+ /**
513
+ * Changes the mute state of a call.
514
+ *
515
+ * The system will emit a {@link SetMutedActionEvent}. Apply the mute state to
516
+ * your media connection when you receive this event.
517
+ *
518
+ * @param id - The call session ID.
519
+ * @param muted - Whether the microphone should be muted.
520
+ *
521
+ * @category Request
522
+ */
523
+ export async function setMuted(id, muted) {
524
+ await ExpoCallKitTelecomModule.setMuted(id, muted);
525
+ }
526
+ /**
527
+ * Subscribes to set muted action events.
528
+ *
529
+ * Fired when the system requests to set the mute state (e.g., user pressed mute button).
530
+ * Apply the change to your media connection when you receive this event.
531
+ *
532
+ * @param listener - Callback invoked when set muted action is requested.
533
+ * @returns A subscription that can be removed by calling `.remove()`.
534
+ *
535
+ * @category Event Listener
536
+ */
537
+ export function addSetMutedActionListener(listener) {
538
+ return ExpoCallKitTelecomModule.addListener("onSetMutedAction", listener);
539
+ }
540
+ // ============================================================================
541
+ // Video Support
542
+ // ============================================================================
543
+ /**
544
+ * Reports a video state change for a call.
545
+ *
546
+ * Use this to inform the system when video is enabled or disabled.
547
+ *
548
+ * @param id - The call session ID.
549
+ * @param enabled - Whether video is enabled.
550
+ *
551
+ * @category Reporter
552
+ */
553
+ export async function reportVideo(id, enabled) {
554
+ await ExpoCallKitTelecomModule.reportVideo(id, enabled);
555
+ }
556
+ /**
557
+ * Subscribes to video state change events.
558
+ *
559
+ * Fired when the video state changes for a call.
560
+ *
561
+ * @param listener - Callback invoked when video state changes.
562
+ * @returns A subscription that can be removed by calling `.remove()`.
563
+ *
564
+ * @category Event Listener
565
+ */
566
+ export function addVideoChangedListener(listener) {
567
+ return ExpoCallKitTelecomModule.addListener("onVideoChanged", listener);
568
+ }
569
+ // ============================================================================
570
+ // Hold Support
571
+ // ============================================================================
572
+ /**
573
+ * Changes the hold state of a call.
574
+ *
575
+ * The system will emit a {@link SetHeldActionEvent}. Apply the hold state to
576
+ * your media connection when you receive this event.
577
+ *
578
+ * @param id - The call session ID.
579
+ * @param onHold - Whether the call should be on hold.
580
+ *
581
+ * @category Request
582
+ */
583
+ export async function setHeld(id, onHold) {
584
+ await ExpoCallKitTelecomModule.setHeld(id, onHold);
585
+ }
586
+ /**
587
+ * Subscribes to set held action events.
588
+ *
589
+ * Fired when the system requests to set the hold state. Apply the change to
590
+ * your media connection when you receive this event.
591
+ *
592
+ * @param listener - Callback invoked when set held action is requested.
593
+ * @returns A subscription that can be removed by calling `.remove()`.
594
+ *
595
+ * @category Event Listener
596
+ */
597
+ export function addSetHeldActionListener(listener) {
598
+ return ExpoCallKitTelecomModule.addListener("onSetHeldAction", listener);
599
+ }
600
+ // ============================================================================
601
+ // DTMF Support
602
+ // ============================================================================
603
+ /**
604
+ * Plays DTMF tones during a call.
605
+ *
606
+ * The system will emit a {@link DTMFEvent}. Send the tones through your media
607
+ * connection when you receive this event.
608
+ *
609
+ * @param id - The call session ID.
610
+ * @param digits - The DTMF digits to play (0-9, *, #).
611
+ *
612
+ * @category Request
613
+ */
614
+ export async function playDTMF(id, digits) {
615
+ await ExpoCallKitTelecomModule.playDTMF(id, digits);
616
+ }
617
+ /**
618
+ * Subscribes to DTMF events.
619
+ *
620
+ * Fired when DTMF tones should be played. Send the tones through your media
621
+ * connection when you receive this event.
622
+ *
623
+ * @param listener - Callback invoked when DTMF tones should be played.
624
+ * @returns A subscription that can be removed by calling `.remove()`.
625
+ *
626
+ * @category Event Listener
627
+ */
628
+ export function addDTMFListener(listener) {
629
+ return ExpoCallKitTelecomModule.addListener("onDTMF", listener);
630
+ }
631
+ // ============================================================================
632
+ // VoIP Push
633
+ // ============================================================================
634
+ /**
635
+ * Registers for VoIP push notifications.
636
+ *
637
+ * Call this early in your app lifecycle to receive VoIP push notifications
638
+ * for incoming calls. Once registered, the device token will be available
639
+ * via {@link getVoIPPushToken} and token updates will be emitted via
640
+ * {@link addVoIPPushTokenUpdatedListener}.
641
+ *
642
+ * @example
643
+ * ```typescript
644
+ * // Register early in app initialization
645
+ * registerVoIPPush();
646
+ *
647
+ * // Listen for token updates
648
+ * addVoIPPushTokenUpdatedListener((event) => {
649
+ * if (event.token) {
650
+ * // Send token to your backend
651
+ * sendTokenToBackend(event.token);
652
+ * }
653
+ * });
654
+ * ```
655
+ *
656
+ * @category VoIP Push
657
+ */
658
+ export function registerVoIPPush() {
659
+ ExpoCallKitTelecomModule.registerVoIPPush();
660
+ }
661
+ /**
662
+ * Gets the current VoIP push token and its type.
663
+ *
664
+ * The token should be sent to your backend along with the token type
665
+ * so the server knows how to deliver incoming call pushes.
666
+ *
667
+ * @returns The VoIP push token bundled with its type, or null if not yet registered.
668
+ *
669
+ * @example
670
+ * ```typescript
671
+ * const voip = getVoIPPushToken();
672
+ * if (voip) {
673
+ * await sendTokenToBackend(voip.token, voip.type);
674
+ * }
675
+ * ```
676
+ *
677
+ * @category VoIP Push
678
+ */
679
+ export function getVoIPPushToken() {
680
+ const result = ExpoCallKitTelecomModule.getVoIPPushToken();
681
+ if (!result.token)
682
+ return null;
683
+ return {
684
+ token: result.token,
685
+ type: result.type,
686
+ };
687
+ }
688
+ /**
689
+ * Subscribes to VoIP token updated events.
690
+ *
691
+ * Fired when the VoIP push token is received or updated after calling
692
+ * {@link registerVoIPPush}. Also fired if the token is invalidated (with
693
+ * `token` being `undefined`).
694
+ *
695
+ * @param listener - Callback invoked when the VoIP token updates.
696
+ * @returns A subscription that can be removed by calling `.remove()`.
697
+ *
698
+ * @example
699
+ * ```typescript
700
+ * const subscription = addVoIPPushTokenUpdatedListener((event) => {
701
+ * if (event.token) {
702
+ * console.log('New VoIP token:', event.token);
703
+ * sendTokenToBackend(event.token);
704
+ * } else {
705
+ * console.log('VoIP token invalidated');
706
+ * }
707
+ * });
708
+ * ```
709
+ *
710
+ * @category VoIP Push Event Listener
711
+ */
712
+ export function addVoIPPushTokenUpdatedListener(listener) {
713
+ return ExpoCallKitTelecomModule.addListener("onVoIPPushTokenUpdated", listener);
714
+ }
715
+ //# sourceMappingURL=Calls.js.map