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.
- package/LICENSE +21 -0
- package/README.md +197 -0
- package/android/build.gradle +32 -0
- package/android/src/main/AndroidManifest.xml +33 -0
- package/android/src/main/java/expo/modules/callkittelecom/ExpoCallKitTelecomModule.kt +384 -0
- package/android/src/main/java/expo/modules/callkittelecom/IncomingCallActivity.kt +275 -0
- package/android/src/main/java/expo/modules/callkittelecom/events/CallEventEmitter.kt +151 -0
- package/android/src/main/java/expo/modules/callkittelecom/events/CallEvents.kt +59 -0
- package/android/src/main/java/expo/modules/callkittelecom/managers/CallAudioManager.kt +361 -0
- package/android/src/main/java/expo/modules/callkittelecom/managers/CallManager.kt +891 -0
- package/android/src/main/java/expo/modules/callkittelecom/managers/CallNotificationManager.kt +445 -0
- package/android/src/main/java/expo/modules/callkittelecom/managers/CaptureSessionManager.kt +27 -0
- package/android/src/main/java/expo/modules/callkittelecom/managers/DialtonePlayer.kt +171 -0
- package/android/src/main/java/expo/modules/callkittelecom/managers/FulfillRequestManager.kt +150 -0
- package/android/src/main/java/expo/modules/callkittelecom/managers/VoIPPushManager.kt +54 -0
- package/android/src/main/java/expo/modules/callkittelecom/models/CallModels.kt +269 -0
- package/android/src/main/java/expo/modules/callkittelecom/services/CallNotificationReceiver.kt +54 -0
- package/android/src/main/java/expo/modules/callkittelecom/services/ExpoCallKitTelecomMessagingService.kt +161 -0
- package/android/src/main/java/expo/modules/callkittelecom/store/CallStore.kt +181 -0
- package/android/src/main/java/expo/modules/callkittelecom/utils/CallKitTelecomLog.kt +52 -0
- package/android/src/main/java/expo/modules/callkittelecom/utils/PermissionUtils.kt +28 -0
- package/android/src/main/res/drawable/expo_callkit_telecom_bg_answer.xml +9 -0
- package/android/src/main/res/drawable/expo_callkit_telecom_bg_avatar.xml +5 -0
- package/android/src/main/res/drawable/expo_callkit_telecom_bg_decline.xml +9 -0
- package/android/src/main/res/drawable/expo_callkit_telecom_ic_answer.xml +9 -0
- package/android/src/main/res/drawable/expo_callkit_telecom_ic_decline.xml +9 -0
- package/android/src/main/res/drawable/expo_callkit_telecom_ic_videocam.xml +9 -0
- package/android/src/main/res/layout/activity_incoming_call.xml +169 -0
- package/app.json +8 -0
- package/app.plugin.js +1 -0
- package/build/Calls.d.ts +577 -0
- package/build/Calls.d.ts.map +1 -0
- package/build/Calls.js +715 -0
- package/build/Calls.js.map +1 -0
- package/build/Calls.types.d.ts +203 -0
- package/build/Calls.types.d.ts.map +1 -0
- package/build/Calls.types.js +2 -0
- package/build/Calls.types.js.map +1 -0
- package/build/ExpoCallKitTelecomModule.d.ts +3 -0
- package/build/ExpoCallKitTelecomModule.d.ts.map +1 -0
- package/build/ExpoCallKitTelecomModule.js +4 -0
- package/build/ExpoCallKitTelecomModule.js.map +1 -0
- package/build/hooks/index.d.ts +2 -0
- package/build/hooks/index.d.ts.map +1 -0
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -0
- package/build/hooks/useVoIPPushToken.d.ts +14 -0
- package/build/hooks/useVoIPPushToken.d.ts.map +1 -0
- package/build/hooks/useVoIPPushToken.js +26 -0
- package/build/hooks/useVoIPPushToken.js.map +1 -0
- package/build/index.d.ts +4 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +4 -0
- package/build/index.js.map +1 -0
- package/expo-module.config.json +10 -0
- package/ios/AppDelegateSubscriber.swift +93 -0
- package/ios/ExpoCallKitTelecom.podspec +31 -0
- package/ios/ExpoCallKitTelecomLogger.swift +55 -0
- package/ios/ExpoCallKitTelecomModule.swift +503 -0
- package/ios/Managers/AudioManager.swift +363 -0
- package/ios/Managers/CallEventEmitter.swift +199 -0
- package/ios/Managers/CallManager+CXProviderDelegate.swift +195 -0
- package/ios/Managers/CallManager.swift +714 -0
- package/ios/Managers/CaptureSessionManager.swift +54 -0
- package/ios/Managers/DialtonePlayer.swift +126 -0
- package/ios/Managers/FulfillRequestManager.swift +154 -0
- package/ios/Managers/VoIPPushManager+PKPushRegistryDelegate.swift +123 -0
- package/ios/Managers/VoIPPushManager.swift +58 -0
- package/ios/Models/CallEvents.swift +263 -0
- package/ios/Models/CallOptions.swift +15 -0
- package/ios/Models/CallParticipant.swift +37 -0
- package/ios/Models/CallSession.swift +80 -0
- package/ios/Models/IncomingCallEvent.swift +196 -0
- package/ios/Stores/CallStore.swift +149 -0
- package/package.json +56 -0
- package/plugin/build/constants.d.ts +3 -0
- package/plugin/build/constants.js +7 -0
- package/plugin/build/withExpoCallKitTelecom.d.ts +67 -0
- package/plugin/build/withExpoCallKitTelecom.js +16 -0
- package/plugin/build/withExpoCallKitTelecomAndroid.d.ts +3 -0
- package/plugin/build/withExpoCallKitTelecomAndroid.js +177 -0
- package/plugin/build/withExpoCallKitTelecomIos.d.ts +3 -0
- package/plugin/build/withExpoCallKitTelecomIos.js +195 -0
- package/plugin/src/constants.ts +4 -0
- package/plugin/src/withExpoCallKitTelecom.ts +83 -0
- package/plugin/src/withExpoCallKitTelecomAndroid.ts +293 -0
- package/plugin/src/withExpoCallKitTelecomIos.ts +276 -0
- package/src/Calls.ts +848 -0
- package/src/Calls.types.ts +275 -0
- package/src/ExpoCallKitTelecomModule.ts +4 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useVoIPPushToken.ts +34 -0
- package/src/index.ts +3 -0
package/build/Calls.d.ts
ADDED
|
@@ -0,0 +1,577 @@
|
|
|
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 type { EventSubscription } from "expo-modules-core";
|
|
52
|
+
import type { AudioRouteChangedEvent, AudioSession, AudioSessionActivatedEvent, AudioSessionDeactivatedEvent, CallAnsweredEvent, CallEndedEvent, CallEndedReason, CallIntentReceivedEvent, CallOptions, CallParticipant, CallReportedEnded, CallSession, CallSessionAddedEvent, CallSessionRemovedEvent, CallSessionUpdatedEvent, CaptureSession, DTMFEvent, IncomingCallEvent, IncomingCallReportedEvent, OutgoingCallStartedEvent, SetHeldActionEvent, SetMutedActionEvent, VideoChangedEvent, VoIPPushToken, VoIPPushTokenUpdatedEvent } from "./Calls.types";
|
|
53
|
+
/**
|
|
54
|
+
* Gets the currently active call session, if any.
|
|
55
|
+
*
|
|
56
|
+
* @returns The active call session, or `null` if no call is in progress.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const session = await getActiveCallSession();
|
|
61
|
+
* if (session) {
|
|
62
|
+
* console.log('Active call with:', session.remoteParticipants[0]?.displayName);
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function getActiveCallSession(): Promise<CallSession | null>;
|
|
67
|
+
/**
|
|
68
|
+
* Subscribes to call session added events.
|
|
69
|
+
*
|
|
70
|
+
* Fired when a new call session is created, either from an outgoing call request
|
|
71
|
+
* or an incoming call report.
|
|
72
|
+
*
|
|
73
|
+
* @param listener - Callback invoked when a session is added.
|
|
74
|
+
* @returns A subscription that can be removed by calling `.remove()`.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const subscription = addCallSessionAddedListener((event) => {
|
|
79
|
+
* console.log('New call session:', event.session.id);
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* // Later, to unsubscribe:
|
|
83
|
+
* subscription.remove();
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function addCallSessionAddedListener(listener: (event: CallSessionAddedEvent) => void): EventSubscription;
|
|
87
|
+
/**
|
|
88
|
+
* Subscribes to call session updated events.
|
|
89
|
+
*
|
|
90
|
+
* Fired when an existing call session's state changes (e.g., status, mute state).
|
|
91
|
+
*
|
|
92
|
+
* @param listener - Callback invoked when a session is updated.
|
|
93
|
+
* @returns A subscription that can be removed by calling `.remove()`.
|
|
94
|
+
*/
|
|
95
|
+
export declare function addCallSessionUpdatedListener(listener: (event: CallSessionUpdatedEvent) => void): EventSubscription;
|
|
96
|
+
/**
|
|
97
|
+
* Subscribes to call session removed events.
|
|
98
|
+
*
|
|
99
|
+
* Fired when a call session is removed after the call has ended and been cleaned up.
|
|
100
|
+
*
|
|
101
|
+
* @param listener - Callback invoked when a session is removed.
|
|
102
|
+
* @returns A subscription that can be removed by calling `.remove()`.
|
|
103
|
+
*/
|
|
104
|
+
export declare function addCallSessionRemovedListener(listener: (event: CallSessionRemovedEvent) => void): EventSubscription;
|
|
105
|
+
/**
|
|
106
|
+
* Gets the current audio session state.
|
|
107
|
+
*
|
|
108
|
+
* Returns information about the audio session including whether it's active,
|
|
109
|
+
* the current category/mode, and the audio route (speaker, earpiece, etc.).
|
|
110
|
+
*
|
|
111
|
+
* @returns The current audio session state.
|
|
112
|
+
*
|
|
113
|
+
* @category Audio
|
|
114
|
+
*/
|
|
115
|
+
export declare function getAudioSession(): AudioSession;
|
|
116
|
+
/**
|
|
117
|
+
* Gets the current capture session state.
|
|
118
|
+
*
|
|
119
|
+
* Returns information about the capture session including camera permission status.
|
|
120
|
+
*
|
|
121
|
+
* @returns The current capture session state.
|
|
122
|
+
*
|
|
123
|
+
* @category Capture
|
|
124
|
+
*/
|
|
125
|
+
export declare function getCaptureSession(): CaptureSession;
|
|
126
|
+
/**
|
|
127
|
+
* Sets the RTC audio session configuration (iOS only).
|
|
128
|
+
*
|
|
129
|
+
* This sets up WebRTC's RTCAudioSession default configuration and enables manual
|
|
130
|
+
* audio management. On Android this is a no-op — audio configuration is handled
|
|
131
|
+
* by {@link prepareAudioSessionForCall}.
|
|
132
|
+
*
|
|
133
|
+
* @param hasVideo - Whether to configure for video calls (uses speaker by default)
|
|
134
|
+
* or audio-only calls (uses earpiece by default).
|
|
135
|
+
*
|
|
136
|
+
* @category Audio
|
|
137
|
+
*/
|
|
138
|
+
export declare function setRTCAudioSessionConfiguration(hasVideo: boolean): void;
|
|
139
|
+
/**
|
|
140
|
+
* Prepares the audio session for an upcoming call.
|
|
141
|
+
*
|
|
142
|
+
* This snapshots the current audio configuration (for later restoration) and
|
|
143
|
+
* pre-configures the audio session for the call. Called automatically when
|
|
144
|
+
* reporting/starting a call, but can be called manually for early preparation.
|
|
145
|
+
*
|
|
146
|
+
* @param hasVideo - Whether to configure for video calls (uses speaker by default)
|
|
147
|
+
* or audio-only calls (uses earpiece by default).
|
|
148
|
+
*
|
|
149
|
+
* @category Audio
|
|
150
|
+
*/
|
|
151
|
+
export declare function prepareAudioSessionForCall(hasVideo: boolean): void;
|
|
152
|
+
/**
|
|
153
|
+
* Restores the audio session to its pre-call configuration.
|
|
154
|
+
*
|
|
155
|
+
* Call this if a call fails to start after prepareAudioSessionForCall was called,
|
|
156
|
+
* or to manually restore the audio session. This is called automatically when
|
|
157
|
+
* the audio session is deactivated after a call ends.
|
|
158
|
+
*
|
|
159
|
+
* @category Audio
|
|
160
|
+
*/
|
|
161
|
+
export declare function restoreAudioSession(): void;
|
|
162
|
+
/**
|
|
163
|
+
* Sets the audio session port override.
|
|
164
|
+
*
|
|
165
|
+
* Use this to route audio to the speaker instead of the earpiece, or vice versa.
|
|
166
|
+
*
|
|
167
|
+
* @param enabled - If `true`, routes audio to the speaker. If `false`, uses
|
|
168
|
+
* the default route (typically earpiece for voice calls).
|
|
169
|
+
*
|
|
170
|
+
* @category Audio
|
|
171
|
+
*/
|
|
172
|
+
export declare function setAudioSessionPortOverride(enabled: boolean): void;
|
|
173
|
+
/**
|
|
174
|
+
* Subscribes to audio session activated events.
|
|
175
|
+
*
|
|
176
|
+
* Fired when the audio session is activated for a call. This is when your
|
|
177
|
+
* app gains exclusive access to audio hardware.
|
|
178
|
+
*
|
|
179
|
+
* @param listener - Callback invoked when audio session activates.
|
|
180
|
+
* @returns A subscription that can be removed by calling `.remove()`.
|
|
181
|
+
*
|
|
182
|
+
* @category Audio Event Listener
|
|
183
|
+
*/
|
|
184
|
+
export declare function addAudioSessionActivatedListener(listener: (event: AudioSessionActivatedEvent) => void): EventSubscription;
|
|
185
|
+
/**
|
|
186
|
+
* Subscribes to audio session deactivated events.
|
|
187
|
+
*
|
|
188
|
+
* Fired when the audio session is deactivated after a call ends.
|
|
189
|
+
*
|
|
190
|
+
* @param listener - Callback invoked when audio session deactivates.
|
|
191
|
+
* @returns A subscription that can be removed by calling `.remove()`.
|
|
192
|
+
*
|
|
193
|
+
* @category Audio Event Listener
|
|
194
|
+
*/
|
|
195
|
+
export declare function addAudioSessionDeactivatedListener(listener: (event: AudioSessionDeactivatedEvent) => void): EventSubscription;
|
|
196
|
+
/**
|
|
197
|
+
* Subscribes to audio route changed events.
|
|
198
|
+
*
|
|
199
|
+
* Fired when the audio route changes (e.g., user connects Bluetooth headphones,
|
|
200
|
+
* toggles speaker mode).
|
|
201
|
+
*
|
|
202
|
+
* @param listener - Callback invoked when audio route changes.
|
|
203
|
+
* @returns A subscription that can be removed by calling `.remove()`.
|
|
204
|
+
*
|
|
205
|
+
* @category Audio Event Listener
|
|
206
|
+
*/
|
|
207
|
+
export declare function addAudioRouteChangedListener(listener: (event: AudioRouteChangedEvent) => void): EventSubscription;
|
|
208
|
+
/**
|
|
209
|
+
* Subscribes to call intent received events.
|
|
210
|
+
*
|
|
211
|
+
* Fired when the user initiates a call from outside the app, such as tapping
|
|
212
|
+
* a contact in the iOS Recents list or via Siri. The event contains the handle
|
|
213
|
+
* (phone number/email) and whether video is requested.
|
|
214
|
+
*
|
|
215
|
+
* The app should resolve the handle to a known recipient and call
|
|
216
|
+
* {@link startOutgoingCall} to fulfill the intent.
|
|
217
|
+
*
|
|
218
|
+
* @param listener - Callback invoked when a call intent is received.
|
|
219
|
+
* @returns A subscription that can be removed by calling `.remove()`.
|
|
220
|
+
*
|
|
221
|
+
* @category Event Listener
|
|
222
|
+
*/
|
|
223
|
+
export declare function addCallIntentReceivedListener(listener: (event: CallIntentReceivedEvent) => void): EventSubscription;
|
|
224
|
+
/**
|
|
225
|
+
* Starts an outgoing call to the specified recipient.
|
|
226
|
+
*
|
|
227
|
+
* This requests the system to initiate a call. The system will display the
|
|
228
|
+
* appropriate call UI and emit an {@link OutgoingCallStartedEvent} when you should
|
|
229
|
+
* begin connecting your media.
|
|
230
|
+
*
|
|
231
|
+
* @param recipient - The participant to call.
|
|
232
|
+
* @param options - Call configuration options (e.g., video enabled).
|
|
233
|
+
* @returns The unique identifier for this call session.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```typescript
|
|
237
|
+
* const callId = await startOutgoingCall(
|
|
238
|
+
* { id: 'user-123', displayName: 'John Doe' },
|
|
239
|
+
* { hasVideo: true }
|
|
240
|
+
* );
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
243
|
+
* @category Request
|
|
244
|
+
*/
|
|
245
|
+
export declare function startOutgoingCall(recipient: CallParticipant, options: CallOptions): Promise<string>;
|
|
246
|
+
/**
|
|
247
|
+
* Subscribes to outgoing call started events.
|
|
248
|
+
*
|
|
249
|
+
* Fired when an outgoing call (initiated via {@link startOutgoingCall}) has
|
|
250
|
+
* been accepted by the system. You should provision your media connection
|
|
251
|
+
* and begin connecting.
|
|
252
|
+
*
|
|
253
|
+
* @param listener - Callback invoked when an outgoing call starts.
|
|
254
|
+
* @returns A subscription that can be removed by calling `.remove()`.
|
|
255
|
+
*
|
|
256
|
+
* @category Event Listener
|
|
257
|
+
*/
|
|
258
|
+
export declare function addOutgoingCallStartedListener(listener: (event: OutgoingCallStartedEvent) => void): EventSubscription;
|
|
259
|
+
/**
|
|
260
|
+
* Reports an incoming call to the system.
|
|
261
|
+
*
|
|
262
|
+
* Call this when you receive a push notification or other signal indicating
|
|
263
|
+
* an incoming call. The system will display the incoming call UI.
|
|
264
|
+
*
|
|
265
|
+
* @param event - The incoming call event containing caller information.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```typescript
|
|
269
|
+
* await reportIncomingCall({
|
|
270
|
+
* callId: '550e8400-e29b-41d4-a716-446655440000',
|
|
271
|
+
* caller: {
|
|
272
|
+
* id: 'user-456',
|
|
273
|
+
* displayName: 'Jane Smith',
|
|
274
|
+
* phoneNumber: '+1234567890',
|
|
275
|
+
* },
|
|
276
|
+
* hasVideo: false,
|
|
277
|
+
* startedAt: new Date(),
|
|
278
|
+
* });
|
|
279
|
+
* ```
|
|
280
|
+
*
|
|
281
|
+
* @category Reporter
|
|
282
|
+
*/
|
|
283
|
+
export declare function reportIncomingCall(event: IncomingCallEvent): Promise<void>;
|
|
284
|
+
/**
|
|
285
|
+
* Subscribes to incoming call reported events.
|
|
286
|
+
*
|
|
287
|
+
* Fired after an incoming call has been successfully reported to the system
|
|
288
|
+
* and the call session has been added to the store. Use this to set up
|
|
289
|
+
* early subscriptions (e.g., call signaling) before the call is answered.
|
|
290
|
+
*
|
|
291
|
+
* @param listener - Callback invoked when an incoming call is reported.
|
|
292
|
+
* @returns A subscription that can be removed by calling `.remove()`.
|
|
293
|
+
*
|
|
294
|
+
* @category Event Listener
|
|
295
|
+
*/
|
|
296
|
+
export declare function addIncomingCallReportedListener(listener: (event: IncomingCallReportedEvent) => void): EventSubscription;
|
|
297
|
+
/**
|
|
298
|
+
* Answers an incoming call.
|
|
299
|
+
*
|
|
300
|
+
* Use this when the user taps an answer button in your app's custom UI.
|
|
301
|
+
* The system will emit a {@link CallAnsweredEvent} to confirm the answer.
|
|
302
|
+
*
|
|
303
|
+
* @param id - The call session ID to answer.
|
|
304
|
+
*
|
|
305
|
+
* @category Request
|
|
306
|
+
*/
|
|
307
|
+
export declare function answerCall(id: string): Promise<void>;
|
|
308
|
+
/**
|
|
309
|
+
* Subscribes to call answered events.
|
|
310
|
+
*
|
|
311
|
+
* Fired when the user answers an incoming call (either from the system UI or
|
|
312
|
+
* via {@link answerCall}). You should begin connecting your media.
|
|
313
|
+
*
|
|
314
|
+
* @param listener - Callback invoked when a call is answered.
|
|
315
|
+
* @returns A subscription that can be removed by calling `.remove()`.
|
|
316
|
+
*
|
|
317
|
+
* @category Event Listener
|
|
318
|
+
*/
|
|
319
|
+
export declare function addCallAnsweredListener(listener: (event: CallAnsweredEvent) => void): EventSubscription;
|
|
320
|
+
/**
|
|
321
|
+
* Fulfills an incoming call by confirming the media connection is established.
|
|
322
|
+
*
|
|
323
|
+
* Call this after the user answers an incoming call and your media connection
|
|
324
|
+
* (e.g., WebRTC) is fully connected and ready for audio/video.
|
|
325
|
+
*
|
|
326
|
+
* @param requestId - The request ID from the CallAnsweredEvent.
|
|
327
|
+
*
|
|
328
|
+
* @category Fulfiller
|
|
329
|
+
*/
|
|
330
|
+
export declare function fulfillIncomingCallConnected(requestId: string): Promise<void>;
|
|
331
|
+
/**
|
|
332
|
+
* Fails a pending incoming call connection request.
|
|
333
|
+
*
|
|
334
|
+
* Call this when the answer flow fails before media is connected
|
|
335
|
+
* (e.g., API error). On iOS, causes CXAnswerCallAction to fail, which
|
|
336
|
+
* triggers CallKit to end the call via CXEndCallAction. On Android,
|
|
337
|
+
* ends the call via {@link reportCallEnded} which also cancels any
|
|
338
|
+
* pending fulfill request.
|
|
339
|
+
*
|
|
340
|
+
* @param id - The call session ID.
|
|
341
|
+
* @param requestId - The request ID from the CallAnsweredEvent.
|
|
342
|
+
*
|
|
343
|
+
* @category Fulfiller
|
|
344
|
+
*/
|
|
345
|
+
export declare function failIncomingCallConnected(id: string, requestId: string): Promise<void>;
|
|
346
|
+
/**
|
|
347
|
+
* Reports that an outgoing call's media connection is established.
|
|
348
|
+
*
|
|
349
|
+
* Call this after starting an outgoing call and your media connection
|
|
350
|
+
* (e.g., WebRTC) is fully connected and the remote party has answered.
|
|
351
|
+
*
|
|
352
|
+
* @param id - The call session ID.
|
|
353
|
+
*
|
|
354
|
+
* @category Reporter
|
|
355
|
+
*/
|
|
356
|
+
export declare function reportOutgoingCallConnected(id: string): Promise<void>;
|
|
357
|
+
/**
|
|
358
|
+
* Ends an active call.
|
|
359
|
+
*
|
|
360
|
+
* Requests the system to end the call. The system will emit a {@link CallEndedEvent}
|
|
361
|
+
* to notify that the call has ended. Clean up your media connection when you receive
|
|
362
|
+
* this event.
|
|
363
|
+
*
|
|
364
|
+
* @param id - The call session ID to end.
|
|
365
|
+
*
|
|
366
|
+
* @category Request
|
|
367
|
+
*/
|
|
368
|
+
export declare function endCall(id: string): Promise<void>;
|
|
369
|
+
/**
|
|
370
|
+
* Subscribes to call ended events.
|
|
371
|
+
*
|
|
372
|
+
* Fired when a call has ended (e.g., user pressed end button).
|
|
373
|
+
* Clean up your media connection when you receive this event.
|
|
374
|
+
*
|
|
375
|
+
* @param listener - Callback invoked when a call ends.
|
|
376
|
+
* @returns A subscription that can be removed by calling `.remove()`.
|
|
377
|
+
*
|
|
378
|
+
* @category Event Listener
|
|
379
|
+
*/
|
|
380
|
+
export declare function addCallEndedListener(listener: (event: CallEndedEvent) => void): EventSubscription;
|
|
381
|
+
/**
|
|
382
|
+
* Reports that a call has ended for an external reason.
|
|
383
|
+
*
|
|
384
|
+
* Use this when a call ends due to reasons outside the local user's control,
|
|
385
|
+
* such as: remote party hung up, network failure, call declined elsewhere, etc.
|
|
386
|
+
*
|
|
387
|
+
* @param id - The call session ID.
|
|
388
|
+
* @param reason - The reason the call ended.
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* ```typescript
|
|
392
|
+
* // Remote party hung up
|
|
393
|
+
* await reportCallEnded(callId, 'remoteEnded');
|
|
394
|
+
*
|
|
395
|
+
* // Call failed due to network error
|
|
396
|
+
* await reportCallEnded(callId, 'failed');
|
|
397
|
+
* ```
|
|
398
|
+
*
|
|
399
|
+
* @category Reporter
|
|
400
|
+
*/
|
|
401
|
+
export declare function reportCallEnded(id: string, reason: CallEndedReason): Promise<void>;
|
|
402
|
+
/**
|
|
403
|
+
* Subscribes to reported call ended events.
|
|
404
|
+
*
|
|
405
|
+
* Fired after {@link reportCallEnded} is called, confirming the system has
|
|
406
|
+
* been notified of the externally-ended call.
|
|
407
|
+
*
|
|
408
|
+
* @param listener - Callback invoked when a call end is reported.
|
|
409
|
+
* @returns A subscription that can be removed by calling `.remove()`.
|
|
410
|
+
*
|
|
411
|
+
* @category Event Listener
|
|
412
|
+
*/
|
|
413
|
+
export declare function addReportedCallEndedListener(listener: (event: CallReportedEnded) => void): EventSubscription;
|
|
414
|
+
/**
|
|
415
|
+
* Changes the mute state of a call.
|
|
416
|
+
*
|
|
417
|
+
* The system will emit a {@link SetMutedActionEvent}. Apply the mute state to
|
|
418
|
+
* your media connection when you receive this event.
|
|
419
|
+
*
|
|
420
|
+
* @param id - The call session ID.
|
|
421
|
+
* @param muted - Whether the microphone should be muted.
|
|
422
|
+
*
|
|
423
|
+
* @category Request
|
|
424
|
+
*/
|
|
425
|
+
export declare function setMuted(id: string, muted: boolean): Promise<void>;
|
|
426
|
+
/**
|
|
427
|
+
* Subscribes to set muted action events.
|
|
428
|
+
*
|
|
429
|
+
* Fired when the system requests to set the mute state (e.g., user pressed mute button).
|
|
430
|
+
* Apply the change to your media connection when you receive this event.
|
|
431
|
+
*
|
|
432
|
+
* @param listener - Callback invoked when set muted action is requested.
|
|
433
|
+
* @returns A subscription that can be removed by calling `.remove()`.
|
|
434
|
+
*
|
|
435
|
+
* @category Event Listener
|
|
436
|
+
*/
|
|
437
|
+
export declare function addSetMutedActionListener(listener: (event: SetMutedActionEvent) => void): EventSubscription;
|
|
438
|
+
/**
|
|
439
|
+
* Reports a video state change for a call.
|
|
440
|
+
*
|
|
441
|
+
* Use this to inform the system when video is enabled or disabled.
|
|
442
|
+
*
|
|
443
|
+
* @param id - The call session ID.
|
|
444
|
+
* @param enabled - Whether video is enabled.
|
|
445
|
+
*
|
|
446
|
+
* @category Reporter
|
|
447
|
+
*/
|
|
448
|
+
export declare function reportVideo(id: string, enabled: boolean): Promise<void>;
|
|
449
|
+
/**
|
|
450
|
+
* Subscribes to video state change events.
|
|
451
|
+
*
|
|
452
|
+
* Fired when the video state changes for a call.
|
|
453
|
+
*
|
|
454
|
+
* @param listener - Callback invoked when video state changes.
|
|
455
|
+
* @returns A subscription that can be removed by calling `.remove()`.
|
|
456
|
+
*
|
|
457
|
+
* @category Event Listener
|
|
458
|
+
*/
|
|
459
|
+
export declare function addVideoChangedListener(listener: (event: VideoChangedEvent) => void): EventSubscription;
|
|
460
|
+
/**
|
|
461
|
+
* Changes the hold state of a call.
|
|
462
|
+
*
|
|
463
|
+
* The system will emit a {@link SetHeldActionEvent}. Apply the hold state to
|
|
464
|
+
* your media connection when you receive this event.
|
|
465
|
+
*
|
|
466
|
+
* @param id - The call session ID.
|
|
467
|
+
* @param onHold - Whether the call should be on hold.
|
|
468
|
+
*
|
|
469
|
+
* @category Request
|
|
470
|
+
*/
|
|
471
|
+
export declare function setHeld(id: string, onHold: boolean): Promise<void>;
|
|
472
|
+
/**
|
|
473
|
+
* Subscribes to set held action events.
|
|
474
|
+
*
|
|
475
|
+
* Fired when the system requests to set the hold state. Apply the change to
|
|
476
|
+
* your media connection when you receive this event.
|
|
477
|
+
*
|
|
478
|
+
* @param listener - Callback invoked when set held action is requested.
|
|
479
|
+
* @returns A subscription that can be removed by calling `.remove()`.
|
|
480
|
+
*
|
|
481
|
+
* @category Event Listener
|
|
482
|
+
*/
|
|
483
|
+
export declare function addSetHeldActionListener(listener: (event: SetHeldActionEvent) => void): EventSubscription;
|
|
484
|
+
/**
|
|
485
|
+
* Plays DTMF tones during a call.
|
|
486
|
+
*
|
|
487
|
+
* The system will emit a {@link DTMFEvent}. Send the tones through your media
|
|
488
|
+
* connection when you receive this event.
|
|
489
|
+
*
|
|
490
|
+
* @param id - The call session ID.
|
|
491
|
+
* @param digits - The DTMF digits to play (0-9, *, #).
|
|
492
|
+
*
|
|
493
|
+
* @category Request
|
|
494
|
+
*/
|
|
495
|
+
export declare function playDTMF(id: string, digits: string): Promise<void>;
|
|
496
|
+
/**
|
|
497
|
+
* Subscribes to DTMF events.
|
|
498
|
+
*
|
|
499
|
+
* Fired when DTMF tones should be played. Send the tones through your media
|
|
500
|
+
* connection when you receive this event.
|
|
501
|
+
*
|
|
502
|
+
* @param listener - Callback invoked when DTMF tones should be played.
|
|
503
|
+
* @returns A subscription that can be removed by calling `.remove()`.
|
|
504
|
+
*
|
|
505
|
+
* @category Event Listener
|
|
506
|
+
*/
|
|
507
|
+
export declare function addDTMFListener(listener: (event: DTMFEvent) => void): EventSubscription;
|
|
508
|
+
/**
|
|
509
|
+
* Registers for VoIP push notifications.
|
|
510
|
+
*
|
|
511
|
+
* Call this early in your app lifecycle to receive VoIP push notifications
|
|
512
|
+
* for incoming calls. Once registered, the device token will be available
|
|
513
|
+
* via {@link getVoIPPushToken} and token updates will be emitted via
|
|
514
|
+
* {@link addVoIPPushTokenUpdatedListener}.
|
|
515
|
+
*
|
|
516
|
+
* @example
|
|
517
|
+
* ```typescript
|
|
518
|
+
* // Register early in app initialization
|
|
519
|
+
* registerVoIPPush();
|
|
520
|
+
*
|
|
521
|
+
* // Listen for token updates
|
|
522
|
+
* addVoIPPushTokenUpdatedListener((event) => {
|
|
523
|
+
* if (event.token) {
|
|
524
|
+
* // Send token to your backend
|
|
525
|
+
* sendTokenToBackend(event.token);
|
|
526
|
+
* }
|
|
527
|
+
* });
|
|
528
|
+
* ```
|
|
529
|
+
*
|
|
530
|
+
* @category VoIP Push
|
|
531
|
+
*/
|
|
532
|
+
export declare function registerVoIPPush(): void;
|
|
533
|
+
/**
|
|
534
|
+
* Gets the current VoIP push token and its type.
|
|
535
|
+
*
|
|
536
|
+
* The token should be sent to your backend along with the token type
|
|
537
|
+
* so the server knows how to deliver incoming call pushes.
|
|
538
|
+
*
|
|
539
|
+
* @returns The VoIP push token bundled with its type, or null if not yet registered.
|
|
540
|
+
*
|
|
541
|
+
* @example
|
|
542
|
+
* ```typescript
|
|
543
|
+
* const voip = getVoIPPushToken();
|
|
544
|
+
* if (voip) {
|
|
545
|
+
* await sendTokenToBackend(voip.token, voip.type);
|
|
546
|
+
* }
|
|
547
|
+
* ```
|
|
548
|
+
*
|
|
549
|
+
* @category VoIP Push
|
|
550
|
+
*/
|
|
551
|
+
export declare function getVoIPPushToken(): VoIPPushToken | null;
|
|
552
|
+
/**
|
|
553
|
+
* Subscribes to VoIP token updated events.
|
|
554
|
+
*
|
|
555
|
+
* Fired when the VoIP push token is received or updated after calling
|
|
556
|
+
* {@link registerVoIPPush}. Also fired if the token is invalidated (with
|
|
557
|
+
* `token` being `undefined`).
|
|
558
|
+
*
|
|
559
|
+
* @param listener - Callback invoked when the VoIP token updates.
|
|
560
|
+
* @returns A subscription that can be removed by calling `.remove()`.
|
|
561
|
+
*
|
|
562
|
+
* @example
|
|
563
|
+
* ```typescript
|
|
564
|
+
* const subscription = addVoIPPushTokenUpdatedListener((event) => {
|
|
565
|
+
* if (event.token) {
|
|
566
|
+
* console.log('New VoIP token:', event.token);
|
|
567
|
+
* sendTokenToBackend(event.token);
|
|
568
|
+
* } else {
|
|
569
|
+
* console.log('VoIP token invalidated');
|
|
570
|
+
* }
|
|
571
|
+
* });
|
|
572
|
+
* ```
|
|
573
|
+
*
|
|
574
|
+
* @category VoIP Push Event Listener
|
|
575
|
+
*/
|
|
576
|
+
export declare function addVoIPPushTokenUpdatedListener(listener: (event: VoIPPushTokenUpdatedEvent) => void): EventSubscription;
|
|
577
|
+
//# sourceMappingURL=Calls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Calls.d.ts","sourceRoot":"","sources":["../src/Calls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAA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