/** * @module Calls * * This module provides APIs for managing VoIP calls with native system integration. * Functions are organized into three categories: * * ## Requests (Imperative) * Functions that initiate actions from the app. These request the system to perform * an operation on behalf of the user: * - {@link startOutgoingCall} - Start a new outgoing call * - {@link answerCall} - Answer an incoming call * - {@link endCall} - End or decline an active call * - {@link setMuted} - Mute/unmute the call * - {@link setHeld} - Hold/unhold the call * - {@link playDTMF} - Play DTMF tones * * ## Reporters * Functions that report state changes to the system. Use these to inform the system * about events that occurred outside of its control (e.g., from your backend or * media connection): * - {@link reportIncomingCall} - Report a new incoming call (e.g., from push notification) * - {@link reportOutgoingCallConnected} - Report that an outgoing call's media is connected * - {@link reportCallEnded} - Report that a call ended externally (e.g., remote hangup) * - {@link reportVideo} - Report video state changes * * ## Fulfillers * Functions that complete pending system requests. When the system requests an action * (via event listeners), your app must perform the action and then call the corresponding * fulfiller to confirm completion: * - {@link fulfillIncomingCallConnected} - Confirm that incoming call media is connected * * ## Typical Flow * * **Outgoing Call:** * 1. Call {@link startOutgoingCall} to initiate * 2. Listen for {@link addCallStartedListener} to know when to connect media * 3. Connect your media (e.g., WebRTC) * 4. Call {@link reportOutgoingCallConnected} when media is ready * * **Incoming Call:** * 1. Receive push notification with call data * 2. Call {@link reportIncomingCall} to show the incoming call UI * 3. Listen for {@link addCallAnsweredListener} to know when user answered * 4. Connect your media (e.g., WebRTC) * 5. Call {@link fulfillIncomingCallConnected} when media is ready * * **Ending a Call:** * - If user ends: Call {@link endCall} and clean up media * - If remote ends: Clean up media, then call {@link reportCallEnded} */ import type { EventSubscription } from "expo-modules-core"; 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"; /** * Gets the currently active call session, if any. * * @returns The active call session, or `null` if no call is in progress. * * @example * ```typescript * const session = await getActiveCallSession(); * if (session) { * console.log('Active call with:', session.remoteParticipants[0]?.displayName); * } * ``` * * @category Sessions */ export declare function getActiveCallSession(): Promise; /** * Subscribes to call session added events. * * Fired when a new call session is created, either from an outgoing call request * or an incoming call report. * * @param listener - Callback invoked when a session is added. * @returns A subscription that can be removed by calling `.remove()`. * * @example * ```typescript * const subscription = addCallSessionAddedListener((event) => { * console.log('New call session:', event.session.id); * }); * * // Later, to unsubscribe: * subscription.remove(); * ``` * * @category Sessions */ export declare function addCallSessionAddedListener(listener: (event: CallSessionAddedEvent) => void): EventSubscription; /** * Subscribes to call session updated events. * * Fired when an existing call session's state changes (e.g., status, mute state). * * @param listener - Callback invoked when a session is updated. * @returns A subscription that can be removed by calling `.remove()`. * * @category Sessions */ export declare function addCallSessionUpdatedListener(listener: (event: CallSessionUpdatedEvent) => void): EventSubscription; /** * Subscribes to call session removed events. * * Fired when a call session is removed after the call has ended and been cleaned up. * * @param listener - Callback invoked when a session is removed. * @returns A subscription that can be removed by calling `.remove()`. * * @category Sessions */ export declare function addCallSessionRemovedListener(listener: (event: CallSessionRemovedEvent) => void): EventSubscription; /** * Gets the current audio session state. * * Returns information about the audio session including whether it's active, * the current category/mode, and the audio route (speaker, earpiece, etc.). * * @returns The current audio session state. * * @category Audio */ export declare function getAudioSession(): AudioSession; /** * Gets the current capture session state. * * Returns information about the capture session including camera permission status. * * @returns The current capture session state. * * @category Capture */ export declare function getCaptureSession(): CaptureSession; /** * Sets the RTC audio session configuration (iOS only). * * This sets up WebRTC's RTCAudioSession default configuration and enables manual * audio management. On Android this is a no-op — audio configuration is handled * by {@link prepareAudioSessionForCall}. * * @param hasVideo - Whether to configure for video calls (uses speaker by default) * or audio-only calls (uses earpiece by default). * * @category Audio */ export declare function setRTCAudioSessionConfiguration(hasVideo: boolean): void; /** * Prepares the audio session for an upcoming call. * * This snapshots the current audio configuration (for later restoration) and * pre-configures the audio session for the call. Called automatically when * reporting/starting a call, but can be called manually for early preparation. * * @param hasVideo - Whether to configure for video calls (uses speaker by default) * or audio-only calls (uses earpiece by default). * * @see {@link restoreAudioSession} — call this after the call ends to revert the session configuration. * @see {@link getAudioSession} — inspect the resulting audio session state. * * @category Audio */ export declare function prepareAudioSessionForCall(hasVideo: boolean): void; /** * Restores the audio session to its pre-call configuration. * * Call this if a call fails to start after prepareAudioSessionForCall was called, * or to manually restore the audio session. This is called automatically when * the audio session is deactivated after a call ends. * * @see {@link prepareAudioSessionForCall} — the matching setup call. * * @category Audio */ export declare function restoreAudioSession(): void; /** * Sets the audio session port override. * * Use this to route audio to the speaker instead of the earpiece, or vice versa. * * @param enabled - If `true`, routes audio to the speaker. If `false`, uses * the default route (typically earpiece for voice calls). * * @category Audio */ export declare function setAudioSessionPortOverride(enabled: boolean): void; /** * Subscribes to audio session activated events. * * Fired when the audio session is activated for a call. This is when your * app gains exclusive access to audio hardware. * * @param listener - Callback invoked when audio session activates. * @returns A subscription that can be removed by calling `.remove()`. * * @category Audio Events */ export declare function addAudioSessionActivatedListener(listener: (event: AudioSessionActivatedEvent) => void): EventSubscription; /** * Subscribes to audio session deactivated events. * * Fired when the audio session is deactivated after a call ends. * * @param listener - Callback invoked when audio session deactivates. * @returns A subscription that can be removed by calling `.remove()`. * * @category Audio Events */ export declare function addAudioSessionDeactivatedListener(listener: (event: AudioSessionDeactivatedEvent) => void): EventSubscription; /** * Subscribes to audio route changed events. * * Fired when the audio route changes (e.g., user connects Bluetooth headphones, * toggles speaker mode). * * @param listener - Callback invoked when audio route changes. * @returns A subscription that can be removed by calling `.remove()`. * * @category Audio Events */ export declare function addAudioRouteChangedListener(listener: (event: AudioRouteChangedEvent) => void): EventSubscription; /** * Subscribes to call intent received events. * * Fired when the user initiates a call from outside the app, such as tapping * a contact in the iOS Recents list or via Siri. The event contains the handle * (phone number/email) and whether video is requested. * * The app should resolve the handle to a known recipient and call * {@link startOutgoingCall} to fulfill the intent. * * @param listener - Callback invoked when a call intent is received. * @returns A subscription that can be removed by calling `.remove()`. * * @category Call Events */ export declare function addCallIntentReceivedListener(listener: (event: CallIntentReceivedEvent) => void): EventSubscription; /** * Starts an outgoing call to the specified recipient. * * This requests the system to initiate a call. The system will display the * appropriate call UI and emit an {@link OutgoingCallStartedEvent} when you should * begin connecting your media. * * @param recipient - The participant to call. * @param options - Call configuration options (e.g., video enabled). * @returns The unique identifier for this call session. * * @example * ```typescript * const callId = await startOutgoingCall( * { id: 'user-123', displayName: 'John Doe' }, * { hasVideo: true } * ); * ``` * * @see {@link addOutgoingCallStartedListener} for the event fired once the OS accepts the call. * @see {@link reportOutgoingCallConnected} to call after the remote media stream is established. * @see {@link endCall} to terminate the call from the app. * * @category Requests */ export declare function startOutgoingCall(recipient: CallParticipant, options: CallOptions): Promise; /** * Subscribes to outgoing call started events. * * Fired when an outgoing call (initiated via {@link startOutgoingCall}) has * been accepted by the system. You should provision your media connection * and begin connecting. * * @param listener - Callback invoked when an outgoing call starts. * @returns A subscription that can be removed by calling `.remove()`. * * @see {@link startOutgoingCall} — the request that triggers this event. * @see {@link reportOutgoingCallConnected} — the next step in the outgoing-call flow. * * @category Call Events */ export declare function addOutgoingCallStartedListener(listener: (event: OutgoingCallStartedEvent) => void): EventSubscription; /** * Reports an incoming call to the system. * * Call this when you receive a push notification or other signal indicating * an incoming call. The system will display the incoming call UI. * * @param event - The incoming call event containing caller information. * * @example * ```typescript * await reportIncomingCall({ * eventId: '550e8400-e29b-41d4-a716-446655440000', * serverCallId: 'srv-abc-123', * caller: { * id: 'user-456', * displayName: 'Jane Smith', * phoneNumber: '+1234567890', * }, * hasVideo: false, * startedAt: '2026-01-15T19:42:11.000Z', * }); * ``` * * @see {@link addIncomingCallReportedListener} — fires once the OS accepts the report. * @see {@link addCallAnsweredListener} — fires when the user answers from the system UI. * @see [VoIP push payload shape](https://expo-callkit-telecom.mfairley.com/voip-push) — the payload that drives this when called from a native push handler. * * @category Reporters */ export declare function reportIncomingCall(event: IncomingCallEvent): Promise; /** * Subscribes to incoming call reported events. * * Fired after an incoming call has been successfully reported to the system * and the call session has been added to the store. Use this to set up * early subscriptions (e.g., call signaling) before the call is answered. * * @param listener - Callback invoked when an incoming call is reported. * @returns A subscription that can be removed by calling `.remove()`. * * @see {@link reportIncomingCall} — the report that triggers this event. * @see {@link addCallAnsweredListener} — fires when the user answers from the system UI. * * @category Call Events */ export declare function addIncomingCallReportedListener(listener: (event: IncomingCallReportedEvent) => void): EventSubscription; /** * Answers an incoming call. * * Use this when the user taps an answer button in your app's custom UI. * The system will emit a {@link CallAnsweredEvent} to confirm the answer. * * @param id - The call session ID to answer. * * @see {@link addCallAnsweredListener} — react to user-initiated answers from the system UI; most apps listen here rather than calling this directly. * @see {@link fulfillIncomingCallConnected} — call after media is established. * @see {@link failIncomingCallConnected} — call if media setup fails. * * @category Requests */ export declare function answerCall(id: string): Promise; /** * Subscribes to call answered events. * * Fired when the user answers an incoming call (either from the system UI or * via {@link answerCall}). You should begin connecting your media. * * @param listener - Callback invoked when a call is answered. * @returns A subscription that can be removed by calling `.remove()`. * * @see {@link answerCall} — the programmatic equivalent (rarely needed; usually the OS UI triggers answering). * @see {@link fulfillIncomingCallConnected} — call after media setup completes. * @see {@link failIncomingCallConnected} — call if media setup fails. * * @category Call Events */ export declare function addCallAnsweredListener(listener: (event: CallAnsweredEvent) => void): EventSubscription; /** * Fulfills an incoming call by confirming the media connection is established. * * Call this after the user answers an incoming call and your media connection * (e.g., WebRTC) is fully connected and ready for audio/video. * * @param requestId - The request ID from the CallAnsweredEvent. * * @see {@link addCallAnsweredListener} — the event you typically respond to before calling this. * @see {@link failIncomingCallConnected} — call this instead if media setup fails. * * @category Fulfillers */ export declare function fulfillIncomingCallConnected(requestId: string): Promise; /** * Fails a pending incoming call connection request. * * Call this when the answer flow fails before media is connected * (e.g., API error). On iOS, causes CXAnswerCallAction to fail, which * triggers CallKit to end the call via CXEndCallAction. On Android, * ends the call via {@link reportCallEnded} which also cancels any * pending fulfill request. * * @param id - The call session ID. * @param requestId - The request ID from the CallAnsweredEvent. * * @see {@link fulfillIncomingCallConnected} — call this on the success path. * @see {@link addCallAnsweredListener} — the event you typically respond to before calling either fulfiller. * * @category Fulfillers */ export declare function failIncomingCallConnected(id: string, requestId: string): Promise; /** * Reports that an outgoing call's media connection is established. * * Call this after starting an outgoing call and your media connection * (e.g., WebRTC) is fully connected and the remote party has answered. * * @param id - The call session ID. * * @see {@link startOutgoingCall} — the call that initiated this outgoing flow. * @see {@link addOutgoingCallStartedListener} — fires when the OS accepts the request. * * @category Reporters */ export declare function reportOutgoingCallConnected(id: string): Promise; /** * Ends an active call. * * Requests the system to end the call. The system will emit a {@link CallEndedEvent} * to notify that the call has ended. Clean up your media connection when you receive * this event. * * @param id - The call session ID to end. * * @see {@link addCallEndedListener} — confirms the call ended. * @see {@link reportCallEnded} — call this instead when the remote party hung up (a server-side signal), so the OS records the right reason. * * @category Requests */ export declare function endCall(id: string): Promise; /** * Subscribes to call ended events. * * Fired when a call has ended (e.g., user pressed end button). * Clean up your media connection when you receive this event. * * @param listener - Callback invoked when a call ends. * @returns A subscription that can be removed by calling `.remove()`. * * @see {@link endCall} — the app-side request that fires this when the user ends from your UI. * @see {@link reportCallEnded} — for remote-initiated ends (server tells you the other party hung up). * * @category Call Events */ export declare function addCallEndedListener(listener: (event: CallEndedEvent) => void): EventSubscription; /** * Reports that a call has ended for an external reason. * * Use this when a call ends due to reasons outside the local user's control, * such as: remote party hung up, network failure, call declined elsewhere, etc. * * @param id - The call session ID. * @param reason - The reason the call ended. * * @example * ```typescript * // Remote party hung up * await reportCallEnded(callId, 'remoteEnded'); * * // Call failed due to network error * await reportCallEnded(callId, 'failed'); * ``` * * @see {@link endCall} — the app-initiated path (your user ended the call). * @see {@link addReportedCallEndedListener} — confirms the OS accepted the report. * * @category Reporters */ export declare function reportCallEnded(id: string, reason: CallEndedReason): Promise; /** * Subscribes to reported call ended events. * * Fired after {@link reportCallEnded} is called, confirming the system has * been notified of the externally-ended call. * * @param listener - Callback invoked when a call end is reported. * @returns A subscription that can be removed by calling `.remove()`. * * @see {@link reportCallEnded} — the report that triggers this event. * * @category Call Events */ export declare function addReportedCallEndedListener(listener: (event: CallReportedEnded) => void): EventSubscription; /** * Changes the mute state of a call. * * The system will emit a {@link SetMutedActionEvent}. Apply the mute state to * your media connection when you receive this event. * * @param id - The call session ID. * @param muted - Whether the microphone should be muted. * * @see {@link addSetMutedActionListener} — fires when the system requests a mute change (e.g. the user pressed mute in the CallKit UI); apply the change to your media stream from there. * * @category Requests */ export declare function setMuted(id: string, muted: boolean): Promise; /** * Subscribes to set muted action events. * * Fired when the system requests to set the mute state (e.g., user pressed mute button). * Apply the change to your media connection when you receive this event. * * @param listener - Callback invoked when set muted action is requested. * @returns A subscription that can be removed by calling `.remove()`. * * @see {@link setMuted} — for the app-initiated direction (programmatic mute toggle). * * @category Call Events */ export declare function addSetMutedActionListener(listener: (event: SetMutedActionEvent) => void): EventSubscription; /** * Reports a video state change for a call. * * Use this to inform the system when video is enabled or disabled. * * @param id - The call session ID. * @param enabled - Whether video is enabled. * * @see {@link addVideoChangedListener} — the inverse direction (system-side video state changes). * * @category Reporters */ export declare function reportVideo(id: string, enabled: boolean): Promise; /** * Subscribes to video state change events. * * Fired when the video state changes for a call. * * @param listener - Callback invoked when video state changes. * @returns A subscription that can be removed by calling `.remove()`. * * @see {@link reportVideo} — for reporting your app's video state changes back to the system. * * @category Call Events */ export declare function addVideoChangedListener(listener: (event: VideoChangedEvent) => void): EventSubscription; /** * Changes the hold state of a call. * * The system will emit a {@link SetHeldActionEvent}. Apply the hold state to * your media connection when you receive this event. * * @param id - The call session ID. * @param onHold - Whether the call should be on hold. * * @see {@link addSetHeldActionListener} — fires when the system requests a hold-state change. * * @category Requests */ export declare function setHeld(id: string, onHold: boolean): Promise; /** * Subscribes to set held action events. * * Fired when the system requests to set the hold state. Apply the change to * your media connection when you receive this event. * * @param listener - Callback invoked when set held action is requested. * @returns A subscription that can be removed by calling `.remove()`. * * @see {@link setHeld} — for the app-initiated direction. * * @category Call Events */ export declare function addSetHeldActionListener(listener: (event: SetHeldActionEvent) => void): EventSubscription; /** * Plays DTMF tones during a call. * * The system will emit a {@link DTMFEvent}. Send the tones through your media * connection when you receive this event. * * @param id - The call session ID. * @param digits - The DTMF digits to play (0-9, *, #). * * @see {@link addDTMFListener} — fires when the system requests DTMF tones (e.g. from the in-call keypad). * * @category Requests */ export declare function playDTMF(id: string, digits: string): Promise; /** * Subscribes to DTMF events. * * Fired when DTMF tones should be played. Send the tones through your media * connection when you receive this event. * * @param listener - Callback invoked when DTMF tones should be played. * @returns A subscription that can be removed by calling `.remove()`. * * @see {@link playDTMF} — for the app-initiated direction (programmatically play tones). * * @category Call Events */ export declare function addDTMFListener(listener: (event: DTMFEvent) => void): EventSubscription; /** * Registers for VoIP push notifications. * * Call this early in your app lifecycle to receive VoIP push notifications * for incoming calls. Once registered, the device token will be available * via {@link getVoIPPushToken} and token updates will be emitted via * {@link addVoIPPushTokenUpdatedListener}. * * @example * ```typescript * // Register early in app initialization * registerVoIPPush(); * * // Listen for token updates * addVoIPPushTokenUpdatedListener((event) => { * if (event.token) { * // Send token to your backend * sendTokenToBackend(event.token); * } * }); * ``` * * @see {@link getVoIPPushToken} — read the current token synchronously after registration. * @see {@link useVoIPPushToken} — React hook that reads the token and subscribes to updates. * @see {@link addVoIPPushTokenUpdatedListener} — non-React subscription to token updates. * * @category VoIP Push */ export declare function registerVoIPPush(): void; /** * Gets the current VoIP push token and its type. * * The token should be sent to your backend along with the token type * so the server knows how to deliver incoming call pushes. * * @returns The VoIP push token bundled with its type, or null if not yet registered. * * @example * ```typescript * const voip = getVoIPPushToken(); * if (voip) { * await sendTokenToBackend(voip.token, voip.type); * } * ``` * * @see {@link registerVoIPPush} — must be called once before a token is available. * @see {@link useVoIPPushToken} — React hook wrapper around this + the update listener. * * @category VoIP Push */ export declare function getVoIPPushToken(): VoIPPushToken | null; /** * Subscribes to VoIP token updated events. * * Fired when the VoIP push token is received or updated after calling * {@link registerVoIPPush}. Also fired if the token is invalidated (with * `token` being `undefined`). * * @param listener - Callback invoked when the VoIP token updates. * @returns A subscription that can be removed by calling `.remove()`. * * @example * ```typescript * const subscription = addVoIPPushTokenUpdatedListener((event) => { * if (event.token) { * console.log('New VoIP token:', event.token); * sendTokenToBackend(event.token); * } else { * console.log('VoIP token invalidated'); * } * }); * ``` * * @see {@link useVoIPPushToken} — React hook that uses this internally; prefer it in components. * @see {@link registerVoIPPush} — must be called once before any token updates fire. * * @category VoIP Push */ export declare function addVoIPPushTokenUpdatedListener(listener: (event: VoIPPushTokenUpdatedEvent) => void): EventSubscription; //# sourceMappingURL=Calls.d.ts.map