### Start Call with Options Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/types.md Example of starting a call with specific configuration options. Ensure InCallManager is imported. ```javascript const options = { media: 'audio', auto: true, ringback: '_BUNDLE_' }; InCallManager.start(options); ``` -------------------------------- ### Incoming Call Setup Example Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/MANIFEST.txt Demonstrates how to set up the InCallManager for an incoming call scenario. This typically involves starting the manager and configuring it for call events. ```javascript InCallManager.start(); InCallManager.setForceSpeakerphoneOn(false); InCallManager.setSpeakerphoneOn(false); InCallManager.setMicrophoneMute(false); InCallManager.setFlashOn(false); InCallManager.chooseAudioRoute('EARPIECE'); ``` -------------------------------- ### Outgoing Call Setup Example Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/MANIFEST.txt Illustrates the setup for an outgoing call. This pattern often involves starting the manager and preparing it for an active call, potentially with specific audio routing. ```javascript InCallManager.start(); InCallManager.setForceSpeakerphoneOn(true); InCallManager.setSpeakerphoneOn(true); InCallManager.setMicrophoneMute(false); InCallManager.setFlashOn(false); InCallManager.chooseAudioRoute('SPEAKER_PHONE'); ``` -------------------------------- ### Headset and Proximity Management Example Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/MANIFEST.txt Demonstrates managing headset and proximity sensor behavior. This includes starting the proximity sensor and setting the audio route based on headset connection. ```javascript InCallManager.startProximitySensor(); // ... later const isWired = yield InCallManager.getIsWiredHeadsetPluggedIn(); if (isWired.isPlugged) { InCallManager.chooseAudioRoute('WIRED_HEADSET'); } else { InCallManager.chooseAudioRoute('EARPIECE'); } ``` -------------------------------- ### InCallManager Configuration Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/_DELIVERY_SUMMARY.txt This guide explains how to configure and set up InCallManager, covering options for starting and stopping the service, ringtone and audio file setup, feature toggles, and audio routing. ```APIDOC ## InCallManager Configuration and Setup This section details the configuration options available for InCallManager, enabling you to customize its behavior according to your application's needs. Key configuration aspects include: - **`start()` and `stop()` Options**: Parameters available when initiating or terminating the InCallManager service. - **Ringtone Configuration**: How to set custom ringtones. - **Audio File Setup**: Instructions for configuring audio files for Android and iOS. - **Feature Toggles**: Options to enable or disable specific features. - **Screen Control Options**: Settings related to screen interactions. - **Audio Routing Options**: Controls for managing audio output devices. - **Platform-Specific Settings**: Configurations tailored for Android and iOS. Refer to `configuration.md` for detailed setup instructions. ``` -------------------------------- ### InCallManager start() Options Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/START-HERE.md Configure the InCallManager when starting. Options include media type, automatic behavior, and ringback tone. ```javascript InCallManager.start({ media: 'audio' | 'video', // Default: 'audio' auto: boolean, // Default: true ringback: string // Default: '' }) ``` -------------------------------- ### Install react-native-incall-manager Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/README.md Install the library using npm. ```bash npm install react-native-incall-manager ``` -------------------------------- ### Manual Android Setup: MainApplication.java Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/README.md Import and instantiate `InCallManagerPackage` in your `MainApplication.java` file. ```java import com.zxcpoiu.incallmanager.InCallManagerPackage; new InCallManagerPackage() ``` -------------------------------- ### Manual Audio Routing Control Example Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/MANIFEST.txt Provides an example of manually controlling audio routing. This allows the application to force the audio to the speakerphone or other routes as needed. ```javascript InCallManager.setForceSpeakerphoneOn(true); // ... later InCallManager.setForceSpeakerphoneOn(false); ``` -------------------------------- ### Flashlight Control (iOS) Example Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/MANIFEST.txt Demonstrates how to control the device's flashlight, typically used for signaling incoming calls or alerts. This example is platform-specific to iOS. ```javascript InCallManager.setFlashOn(true); // ... later InCallManager.setFlashOn(false); ``` -------------------------------- ### Video Call Configuration Example Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/MANIFEST.txt Configures InCallManager for a video call. This example focuses on ensuring the screen remains on and the audio route is set appropriately for a video conferencing scenario. ```javascript InCallManager.start({ media: 'video', auto: true, ringback: '', incall: '', // ... other options }); InCallManager.setKeepScreenOn(true); InCallManager.setSpeakerphoneOn(false); InCallManager.setMicrophoneMute(false); ``` -------------------------------- ### Manual iOS Setup: Xcode Project Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/README.md Add the library's project file to your Xcode project and link the static library. ```bash Drag `node_modules/react-native-incall-manager/ios/RNInCallManager.xcodeproj` into Xcode Add `libRNInCallManager.a` to "Link Binary With Libraries" Add header search path: `$(SRCROOT)/../node_modules/react-native-incall-manager/ios/RNInCallManager` ``` -------------------------------- ### start Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/README.md Starts the incall manager. It can automatically manage call states or be controlled manually. Optionally plays a ringback tone. ```APIDOC ## start(`{media: ?string, auto: ?boolean, ringback: ?string}`) ### Description Starts the incall manager. - `media`: Specifies the media type ('audio' or 'video'). Defaults to 'audio'. - `auto`: If true, automatically manages call states. Defaults to true. - `ringback`: A non-empty string to play a ringback tone. If empty or not provided, no ringback is played. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **media** (string) - Optional - Specifies the media type ('audio' or 'video'). - **auto** (boolean) - Optional - If true, automatically manages call states. - **ringback** (string) - Optional - A non-empty string to play a ringback tone. ### Request Example ```json { "media": "audio", "auto": true, "ringback": "_DEFAULT_" } ``` ### Response #### Success Response (200) No specific response body documented. ``` -------------------------------- ### Start Ringback Separately (Busytone Context) Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/configuration.md Demonstrates starting a ringback tone independently, though this method is also used for busytone playback in certain contexts. Note the use of startRingback() for this purpose. ```javascript // Not commonly used separately, but available InCallManager.startRingback('_DEFAULT_'); // Note: uses startRingback() ``` -------------------------------- ### Screen Control (Android) Example Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/MANIFEST.txt Shows how to control the device's screen behavior, specifically keeping it on, which is useful during active calls or other foreground activities. This example is platform-specific to Android. ```javascript InCallManager.setKeepScreenOn(true); // ... later InCallManager.setKeepScreenOn(false); ``` -------------------------------- ### Start InCallManager with Basic Audio Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/api-reference/InCallManager.md Starts the in-call manager for a basic audio call, configuring audio routing and enabling the proximity sensor. ```javascript InCallManager.start({ media: 'audio' }); ``` -------------------------------- ### Audio Focus Management (Android) Example Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/MANIFEST.txt Shows how to request and abandon audio focus, a critical feature for Android applications to manage audio playback and avoid conflicts with other apps. This example is platform-specific to Android. ```javascript InCallManager.requestAudioFocus(); // ... later InCallManager.abandonAudioFocus(); ``` -------------------------------- ### Headset State Detection Example Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/MANIFEST.txt Provides an example of detecting whether a wired headset is plugged into the device. This information can be used to adjust audio routing. ```javascript const wiredHeadsetInfo = yield InCallManager.getIsWiredHeadsetPluggedIn(); if (wiredHeadsetInfo.isPlugged) { console.log('Wired headset is plugged in.'); } else { console.log('Wired headset is not plugged in.'); } ``` -------------------------------- ### Complete Call Flow Example Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/api-reference/InCallManager.md Demonstrates a typical sequence of InCallManager calls for handling an incoming call, managing the call in progress, and ending the call. ```javascript import InCallManager from 'react-native-incall-manager'; // Incoming call InCallManager.startRingtone('_BUNDLE_'); // User answers InCallManager.stopRingtone(); InCallManager.start({ media: 'audio' }); // ... call in progress ... // User hangs up InCallManager.stop(); ``` -------------------------------- ### Lifecycle Methods Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/README.md Methods to initialize and clean up the call manager. `start` initializes the manager, typically with audio routing settings, while `stop` cleans up and restores device settings. ```APIDOC ## start(setup?) ### Description Initialize call manager with audio routing. ### Method JavaScript ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **setup** (object) - Optional - Setup options for the call manager, e.g., `{ media: 'audio' }`. ### Request Example ```javascript InCallManager.start({ media: 'audio' }); ``` ### Response #### Success Response void #### Response Example None ## stop(setup?) ### Description Clean up and restore settings. ### Method JavaScript ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **setup** (object) - Optional - Setup options for stopping the call manager. ### Request Example ```javascript InCallManager.stop(); ``` ### Response #### Success Response void #### Response Example None ``` -------------------------------- ### Start Call Management Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/module-structure.md Begin call management, setting the media type to audio. This also configures audio routing, proximity sensor, and screen-on flag. ```javascript InCallManager.start({media: 'audio'}) ``` -------------------------------- ### Microphone and Speaker Control Example Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/MANIFEST.txt Demonstrates how to mute/unmute the microphone and control the speakerphone. These are fundamental controls for managing audio during a call. ```javascript InCallManager.setMicrophoneMute(true); // ... later InCallManager.setMicrophoneMute(false); InCallManager.setSpeakerphoneOn(true); ``` -------------------------------- ### InCallManager.start Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/types.md Configures and starts the InCallManager. It allows setting options for audio routing, media type, and ringback tones. ```APIDOC ## InCallManager.start ### Description Configures and starts the InCallManager with specified options. ### Method `start(setup: StartOptions)` ### Parameters #### Request Body - **auto** (boolean) - Optional - Enable automatic audio routing based on media type and device state. Defaults to `true`. - **media** (string) - Optional - Call media type. Determines initial audio routing. Defaults to `"audio"`. - **ringback** (string) - Optional - Ringback tone identifier. Use `'_BUNDLE_'`, `'_DEFAULT_'`, or `'_DTMF_'`. Defaults to `""`. ### Request Example ```javascript const options = { media: 'audio', auto: true, ringback: '_BUNDLE_' }; InCallManager.start(options); ``` ### Response This method does not return a value. ``` -------------------------------- ### State Machine for Call Management Example Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/MANIFEST.txt Conceptual example of using a state machine to manage the complex states of a call. This pattern helps in organizing the logic for different call phases like ringing, connected, disconnected, etc. ```javascript const callState = { INITIAL: 'initial', RINGING: 'ringing', CONNECTED: 'connected', DISCONNECTED: 'disconnected', }; let currentState = callState.INITIAL; function transitionTo(newState) { currentState = newState; switch (currentState) { case callState.RINGING: InCallManager.startRingtone(); break; case callState.CONNECTED: InCallManager.stopRingtone(); InCallManager.setSpeakerphoneOn(false); break; case callState.DISCONNECTED: InCallManager.stop(); break; } } ``` -------------------------------- ### Audio File Management Example Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/MANIFEST.txt Illustrates how to play specific audio files, such as ringtones or ringback tones, using InCallManager. This involves specifying the audio URI and managing playback. ```javascript const ringbackSound = InCallManager.getAudioUri('ringback'); InCallManager.startRingback({ media: 'audio', filename: ringbackSound }); // ... later InCallManager.stopRingback(); ``` -------------------------------- ### Start Ringtone with Default Settings Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/configuration.md Initiate the default system ringtone. No custom vibration or audio category is specified. ```javascript InCallManager.startRingtone('_DEFAULT_'); ``` -------------------------------- ### Start and Stop Call Manager Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/README.md Initialize the call manager for audio mode and stop it to clean up resources. ```javascript // Start call manager (audio mode) InCallManager.start({ media: 'audio' }); // Stop call manager InCallManager.stop(); ``` -------------------------------- ### Start InCallManager with Default Audio Configuration Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/configuration.md Initiates a default audio call. This is equivalent to specifying `{ media: 'audio', auto: true, ringback: '' }`. ```javascript InCallManager.start(); // Equivalent to: { media: 'audio', auto: true, ringback: '' } ``` -------------------------------- ### Start Ringtone with Custom Bundled Sound and Vibration Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/configuration.md Play a custom ringtone from the application bundle along with a specified vibration pattern. ```javascript InCallManager.startRingtone('_BUNDLE_', [100, 200, 100]); // 100ms buzz, 200ms silence, 100ms buzz pattern ``` -------------------------------- ### Start InCallManager with Video Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/README.md Configure the InCallManager for video calls. The default media type is 'audio', so 'video' must be explicitly set if needed. ```javascript start({ media: 'video' }) ``` -------------------------------- ### Proximity Sensor Methods Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/INDEX.md Methods to start and stop the proximity sensor. ```APIDOC ## startProximitySensor ### Description Starts monitoring the proximity sensor. ### Method `startProximitySensor()` ### Parameters None ### Response No specific response documented. ## stopProximitySensor ### Description Stops monitoring the proximity sensor. ### Method `stopProximitySensor()` ### Parameters None ### Response No specific response documented. ``` -------------------------------- ### Ringtone Methods Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/INDEX.md Methods to manage ringtones, including starting and stopping them. ```APIDOC ## startRingtone ### Description Starts playing a ringtone with optional vibration and duration. ### Method `startRingtone(ringtone, vibrate, category, seconds)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **ringtone** (string) - The path or URI to the ringtone file. - **vibrate** (boolean) - Whether to vibrate the device. - **category** (string) - iOS category for the ringtone. - **seconds** (number) - The duration in seconds to play the ringtone. ### Response No specific response documented. ## stopRingtone ### Description Stops the currently playing ringtone. ### Method `stopRingtone()` ### Parameters None ### Response No specific response documented. ``` -------------------------------- ### Error Handling and Cleanup Example Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/MANIFEST.txt Illustrates best practices for error handling and cleaning up resources when using InCallManager. This includes stopping the manager and abandoning audio focus when the component unmounts or an error occurs. ```javascript componentWillUnmount() { InCallManager.stop(); InCallManager.abandonAudioFocus(); } ``` -------------------------------- ### Device Methods Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/INDEX.md Methods to get information about the device's hardware. ```APIDOC ## getIsWiredHeadsetPluggedIn ### Description Checks if a wired headset is plugged into the device. ### Method `getIsWiredHeadsetPluggedIn()` ### Parameters None ### Response - **isPlugged** (boolean) - `true` if a wired headset is plugged in, `false` otherwise. ``` -------------------------------- ### Start InCallManager with Manual Audio Routing Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/configuration.md Starts an audio call while disabling automatic sensor events and audio routing. Manual control over routing is required when `auto` is set to `false`. ```javascript InCallManager.start({ media: 'audio', auto: false // You control all routing manually }); ``` -------------------------------- ### Lifecycle Methods Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/INDEX.md Methods to manage the lifecycle of the InCallManager, including starting and stopping its services. ```APIDOC ## start ### Description Starts the InCallManager service with optional setup configuration. ### Method `start(setup)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **setup** (object) - Optional - Configuration object for starting the service. See Configuration Keys for details. ### Request Example ```json { "media": "audio", "auto": true, "ringback": "/path/to/ringback.mp3" } ``` ### Response No specific response documented. ## stop ### Description Stops the InCallManager service. ### Method `stop(setup)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **setup** (object) - Optional - Configuration object for stopping the service. See Configuration Keys for details. ### Request Example ```json { "busytone": "/path/to/busytone.mp3" } ``` ### Response No specific response documented. ``` -------------------------------- ### Incoming Call Setup with Ringtone Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/usage-patterns.md Use this pattern to play a ringtone for incoming calls before the user answers. Ensure to stop the ringtone when the call is accepted or declined. ```javascript import InCallManager from 'react-native-incall-manager'; async function handleIncomingCall() { // Step 1: Play ringtone to alert user InCallManager.startRingtone('_BUNDLE_'); // Step 2: Wait for user action (answer or decline) // ... user interface shows accept/decline buttons ... } ``` ```javascript async function acceptIncomingCall() { // Step 1: Stop ringtone InCallManager.stopRingtone(); // Step 2: Initialize call manager with audio routing InCallManager.start({ media: 'audio' }); // Step 3: Establish WebRTC connection // ... your WebRTC code ... } ``` ```javascript async function declineIncomingCall() { // Simply stop ringtone without starting call manager InCallManager.stopRingtone(); } ``` -------------------------------- ### Call Manager with Event Listeners and Cleanup Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/usage-patterns.md Manages call lifecycle, including starting and stopping calls, setting up event listeners for proximity and headset events, and ensuring proper cleanup of listeners. Includes error handling for call start and stop operations. ```javascript export default class CallManager { constructor() { this.listeners = []; this.isCallActive = false; } async startCall() { try { InCallManager.start({ media: 'audio' }); this.setupEventListeners(); this.isCallActive = true; } catch (error) { console.error('Failed to start call:', error); this.cleanup(); } } async stopCall() { try { InCallManager.stop(); this.isCallActive = false; } catch (error) { console.error('Failed to stop call:', error); } finally { this.cleanup(); } } setupEventListeners() { const proximityListener = DeviceEventEmitter.addListener( 'Proximity', (data) => this.handleProximity(data) ); this.listeners.push(proximityListener); const headsetListener = DeviceEventEmitter.addListener( 'WiredHeadset', (data) => this.handleHeadset(data) ); this.listeners.push(headsetListener); } cleanup() { // Remove all event listeners this.listeners.forEach(listener => listener.remove()); this.listeners = []; } handleProximity(data) { console.log('Proximity:', data.isNear); } handleHeadset(data) { console.log('Headset:', data); } } ``` -------------------------------- ### Listen for Media Button Events Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/types.md Example of how to listen for and handle media button events, such as headset hook presses, using DeviceEventEmitter. ```javascript import { DeviceEventEmitter } from 'react-native'; DeviceEventEmitter.addListener('MediaButton', (event) => { console.log(`Button pressed: ${event.eventText} (code: ${event.eventCode})`); if (event.eventText === 'HEADSETHOOK') { // Handle headset button press } }); ``` -------------------------------- ### Error Handling Example: Invalid Audio Type and Platform Unsupported Features Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/module-structure.md Demonstrates how the InCallManager handles errors. Invalid audio types return null, and platform-unsupported features are logged instead of throwing exceptions. ```javascript // Invalid audio type returns null const uri = await InCallManager.getAudioUri('invalid', '_BUNDLE_'); // null // Platform-unsupported features log instead of throwing InCallManager.setFlashOn(true); // Logs on Android, works on iOS ``` -------------------------------- ### Start Ringtone for Incoming Call Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/module-structure.md Initiate the ringtone playback for an incoming call using InCallManager.startRingtone. Replace '_BUNDLE_' with the appropriate ringtone asset identifier. ```javascript InCallManager.startRingtone('_BUNDLE_') ``` -------------------------------- ### Start InCallManager with Audio Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/README.md Configure the InCallManager to manage audio routing. Set auto to false to disable automatic behavior and specify a ringback tone source. ```javascript start({ media: 'audio', auto: false, ringback: '_DTMF_' }) ``` -------------------------------- ### Start InCallManager with Custom Bundle Ringback Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/configuration.md Initiates an audio call with a custom ringback tone loaded from the application bundle. Ensure the ringback file is correctly bundled. ```javascript InCallManager.start({ media: 'audio', ringback: '_BUNDLE_' }); ``` -------------------------------- ### Outgoing Call Setup with Ringback Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/usage-patterns.md Initiate outgoing calls and play a ringback tone while waiting for the callee to answer. Remember to stop the ringback when the callee answers or the call fails. ```javascript async function initiateOutgoingCall(phoneNumber) { // Step 1: Start call manager with ringback InCallManager.start({ media: 'audio', ringback: '_BUNDLE_' }); // Step 2: Initiate WebRTC connection // ... your WebRTC code ... } ``` ```javascript async function onCalleeAnswered() { // Step 1: Stop ringback tone InCallManager.stopRingback(); // Step 2: Continue with active call // Audio routing already configured by start() } ``` ```javascript async function onCallFailed() { // Step 1: Stop call manager with busytone InCallManager.stop({ busytone: '_DTMF_' // Play DTMF tone pattern }); // Step 2: Show error to user // ... your error handling ... } ``` -------------------------------- ### InCallManager Lifecycle Methods Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/START-HERE.md Methods to initialize and stop the call manager. The `start` method accepts configuration options for media type, auto-start behavior, and ringback tone. The `stop` method can be used to stop the call manager and specify a busy tone. ```APIDOC ## `start()` ### Description Initializes the call manager. ### Method `InCallManager.start(options)` ### Parameters #### Options - **media** (string) - Optional - Specifies the media type, either 'audio' or 'video'. Defaults to 'audio'. - **auto** (boolean) - Optional - Determines if the call manager should auto-start. Defaults to true. - **ringback** (string) - Optional - Sets the ringback tone. ## `stop()` ### Description Stops the call manager. ### Method `InCallManager.stop(options)` ### Parameters #### Options - **busytone** (string) - Optional - Specifies the busy tone to play. ``` -------------------------------- ### Start Call with Ringback Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/configuration.md Initiates a call with audio media and a specified ringback tone. The ringback must be explicitly stopped when the callee answers. ```javascript InCallManager.start({ media: 'audio', ringback: '_BUNDLE_' }); // Must explicitly stop when callee answers InCallManager.stopRingback(); ``` -------------------------------- ### Listen for Audio Focus Changes Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/types.md Example of how to listen for and react to audio focus changes on Android, such as gaining or losing focus, using DeviceEventEmitter. ```javascript import { DeviceEventEmitter } from 'react-native'; DeviceEventEmitter.addListener('onAudioFocusChange', (event) => { console.log(`Audio focus: ${event.eventText} (code: ${event.eventCode})`); if (event.eventText === 'AUDIOFOCUS_LOSS') { // Pause playback, release resources } }); ``` -------------------------------- ### Outgoing Call Flow Example Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/api-reference/InCallManager.md Illustrates the InCallManager usage pattern for initiating an outgoing call, handling the callee's answer, and managing the call lifecycle until it ends. ```javascript // User initiates call InCallManager.start({ media: 'audio', ringback: '_BUNDLE_' }); // Callee answers InCallManager.stopRingback(); // ... call in progress ... // Call ends InCallManager.stop({ busytone: '_DTMF_' }); ``` -------------------------------- ### Initialize Call Audio with Headset Detection Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/usage-patterns.md Initializes call audio, first checking the headset status to determine appropriate audio routing. Starts the InCallManager with audio media. ```javascript async function initializeCallAudio() { const headsetConnected = await checkHeadsetStatus(); if (headsetConnected) { console.log('Routing audio to wired headset'); } else { console.log('Using default audio routing'); } InCallManager.start({ media: 'audio' }); } ``` -------------------------------- ### Start and Stop Call Manager Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/README.md Initiate and terminate the InCallManager for audio or video calls. Ensure to stop the manager when the call ends to clean up event listeners. ```javascript import InCallManager from 'react-native-incall-manager'; // --- start manager when the chat start based on logics of your app // On Call Established: InCallManager.start({media: 'audio'}); // audio/video, default: audio // ... it will also register and emit events ... // --- On Call Hangup: InCallManager.stop(); // ... it will also remove event listeners ... ``` -------------------------------- ### Platform-Specific Code Example Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/MANIFEST.txt Shows how to include platform-specific code within your React Native application. This is essential for features that behave differently or are only available on certain platforms like Android or iOS. ```javascript import { Platform } from 'react-native'; if (Platform.OS === 'android') { // Android specific code InCallManager.requestAudioFocus(); } else if (Platform.OS === 'ios') { // iOS specific code InCallManager.setFlashOn(true); } ``` -------------------------------- ### InCallManager Methods Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/_DELIVERY_SUMMARY.txt This section details the 28 public methods available in the InCallManager API. Each method includes its full signature, parameter tables, return types, platform support, behavior descriptions, and code examples. ```APIDOC ## InCallManager Methods This section provides a comprehensive reference for all 28 public methods exposed by the InCallManager API. For each method, you will find detailed information including: - **Full Signatures**: The exact method signature as it appears in the SDK. - **Parameter Tables**: A breakdown of each parameter, its type, whether it's required or optional, and a description of its purpose. - **Return Types**: The data type of the value returned by the method. - **Platform Support**: Clear indication of which platforms (Android, iOS) the method is supported on. - **Behavior Descriptions**: An explanation of what the method does and how it behaves. - **Code Examples**: Practical examples demonstrating how to use the method in your application. Refer to `api-reference/InCallManager.md` for specific method details. ``` -------------------------------- ### Start Call with Ringback Tone Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/module-structure.md Initiate call management for an outgoing call, specifying the media type and a ringback tone. Replace '_BUNDLE_' with the appropriate ringback asset identifier. ```javascript InCallManager.start({ media: 'audio', ringback: '_BUNDLE_' }) ``` -------------------------------- ### Start InCallManager with Ringback Tone Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/api-reference/InCallManager.md Starts the in-call manager for an outgoing call and plays a ringback tone from the bundle. ```javascript InCallManager.start({ media: 'audio', ringback: '_BUNDLE_' }); ``` -------------------------------- ### Start InCallManager with Auto Routing Disabled Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/api-reference/InCallManager.md Starts the in-call manager for an audio call but disables automatic audio routing behavior. ```javascript InCallManager.start({ media: 'audio', auto: false }); ``` -------------------------------- ### Start InCallManager for Video Call Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/api-reference/InCallManager.md Starts the in-call manager for a video call, routing audio to the speaker and disabling the proximity sensor. ```javascript InCallManager.start({ media: 'video', auto: true }); ``` -------------------------------- ### Start Ringback Independently Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/configuration.md Starts playing a ringback tone separately from call initiation. This tone can be stopped later using stopRingback(). ```javascript // Start ringback independently InCallManager.startRingback('_DEFAULT_'); // Stop it later InCallManager.stopRingback(); ``` -------------------------------- ### Start Ringback Tone Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/api-reference/InCallManager.md Plays a ringback tone for outgoing calls. Use this method separately only if not using the start() method. Supported on Android and iOS. ```javascript InCallManager.startRingback('_BUNDLE_'); // With DTMF tones InCallManager.startRingback('_DTMF_'); ``` -------------------------------- ### IncallManager Configuration for startRingtone() Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/INDEX.md Configuration options for the `startRingtone()` method in IncallManager. Define the ringtone, vibration pattern, iOS category, and duration. ```javascript // startRingtone() (ringtone, vibrate_pattern, ios_category, seconds) ``` -------------------------------- ### Start Video Call with InCallManager Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/usage-patterns.md Initiates a call in video mode, automatically handling speaker routing and disabling the proximity sensor. Use this when starting a video call. ```javascript async function startVideoCall() { // Start with video mode InCallManager.start({ media: 'video', // Speaker routing instead of earpiece auto: true // Auto-handle audio events }); // Video calls commonly use speaker // Proximity sensor is disabled for video // ... your video WebRTC setup ... } ``` -------------------------------- ### StartOptions Interface Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/types.md Defines the configuration object for InCallManager.start(). Use to control call media type, automatic routing, and ringback tones. ```typescript interface StartOptions { auto?: boolean; media?: "audio" | "video"; ringback?: string; } ``` -------------------------------- ### File Organization Structure Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/INDEX.md Illustrates the directory structure of the react-native-incall-manager project, showing the location of various documentation files. ```bash output/ ├── INDEX.md # This file - complete documentation index ├── README.md # Overview and quick reference guide ├── api-reference/ │ └── InCallManager.md # Complete API method reference ├── types.md # Type definitions and interfaces ├── events.md # Event system reference ├── configuration.md # Configuration and setup guide ├── module-structure.md # Architecture and implementation details └── usage-patterns.md # Common usage patterns with examples ``` -------------------------------- ### Android Manual Linking: settings.gradle Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/README.md Include these lines in your settings.gradle file for manual linking. ```gradle include ':react-native-incall-manager' project(':react-native-incall-manager').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-incall-manager/android') ``` -------------------------------- ### Android Manual Linking: MainApplication.java Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/README.md Add the InCallManagerPackage to your MainApplication.java for manual linking. ```java import com.zxcpoiu.incallmanager.InCallManagerPackage; private static List getPackages() { return Arrays.asList( new MainReactPackage(), new InCallManagerPackage() ); } ``` -------------------------------- ### Stop Call with Options Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/types.md Example of stopping a call with a specified busytone. Ensure InCallManager is imported. ```javascript const options = { busytone: '_DEFAULT_' }; InCallManager.stop(options); ``` -------------------------------- ### Using the Singleton Instance Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/module-structure.md Interact with the module by importing the default export, which is the singleton instance. This ensures all operations and cache accesses are directed to the same object. ```javascript import InCallManager from 'react-native-incall-manager'; // Always operates on same instance InCallManager.start(); InCallManager.stop(); // Cache is shared const uri = await InCallManager.getAudioUri('ringtone', '_BUNDLE_'); ``` -------------------------------- ### Start Ringtone Playback Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/api-reference/InCallManager.md Plays a ringtone to notify of an incoming call, with options for vibration and duration. Supported on Android and iOS. ```javascript // Simple ringtone with default settings InCallManager.startRingtone('_BUNDLE_'); // Custom filename InCallManager.startRingtone('my_ringtone.mp3'); // With vibration pattern InCallManager.startRingtone('_DEFAULT_', [100, 200, 100]); // iOS with specific audio category InCallManager.startRingtone('_BUNDLE_', undefined, 'playback'); // Android with 15-second timeout InCallManager.startRingtone('_BUNDLE_', undefined, undefined, 15); // Complete configuration InCallManager.startRingtone('_DEFAULT_', [100, 200], 'playback', 30); ``` -------------------------------- ### Start Ringtone with iOS Audio Category Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/configuration.md Configure the ringtone to use the 'playback' audio category specifically for iOS devices. ```javascript InCallManager.startRingtone('_DEFAULT_', undefined, 'playback'); ``` -------------------------------- ### turnScreenOn Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/README.md Forces the device screen to turn on. ```APIDOC ## turnScreenOn() ### Description Forces the device screen to turn on. ### Method POST (assumed, as it's an action) ### Endpoint /turnScreenOn ### Parameters None ### Response #### Success Response (200) No specific response body documented. ``` -------------------------------- ### Start InCallManager for Video Call Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/configuration.md Configures InCallManager for a video call. This routes audio to the speaker and disables the proximity sensor. ```javascript InCallManager.start({ media: 'video' }); // Routes audio to speaker, disables proximity sensor ``` -------------------------------- ### Start Ringtone with Android Timeout Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/configuration.md Set a specific duration for the ringtone playback on Android devices. A value of 15 seconds is used here. ```javascript InCallManager.startRingtone('_BUNDLE_', undefined, undefined, 15); ``` -------------------------------- ### chooseAudioRoute() Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/api-reference/InCallManager.md Requests a specific audio route, returning the result from the native implementation. The structure of the returned result may vary by platform. ```APIDOC ## chooseAudioRoute(route: string) ### Description Requests a specific audio route. Returns the result from native implementation. ### Parameters #### Path Parameters - **route** (string) - Required - Audio route identifier (platform-specific) ### Return `Promise` — Result from native module (structure varies by platform) ### Platform Support Android and iOS ### Example ```javascript // Choose specific audio route const result = await InCallManager.chooseAudioRoute('speaker'); console.log('Route result:', result); ``` ``` -------------------------------- ### Play and Stop Ringtone Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/README.md Play an incoming call ringtone and stop it when the user answers. Ensure to start the call manager after stopping the ringtone. ```javascript // Play incoming call ringtone InCallManager.startRingtone('_BUNDLE_'); // Stop ringtone when user answers InCallManager.stopRingtone(); InCallManager.start({ media: 'audio' }); // Stop call InCallManager.stop(); ``` -------------------------------- ### Accessing and Fetching Audio URIs Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/types.md Demonstrates how to directly access cached audio URIs from the `InCallManager.audioUriMap` and how to fetch and automatically cache a URI using `InCallManager.getAudioUri`. ```javascript // Direct access to cached value if (InCallManager.audioUriMap.ringtone._BUNDLE_) { console.log('Cached ringtone URI:', InCallManager.audioUriMap.ringtone._BUNDLE_); } // Fetch and auto-cache const uri = await InCallManager.getAudioUri('ringtone', '_BUNDLE_'); // Now available in: InCallManager.audioUriMap.ringtone._BUNDLE_ ``` -------------------------------- ### Usage Patterns Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/api-reference/InCallManager.md Demonstrates common usage patterns for the InCallManager API, including call flows and event listening. ```APIDOC ## Usage Patterns ### Complete Call Flow ```javascript import InCallManager from 'react-native-incall-manager'; // Incoming call InCallManager.startRingtone('_BUNDLE_'); // User answers InCallManager.stopRingtone(); InCallManager.start({ media: 'audio' }); // ... call in progress ... // User hangs up InCallManager.stop(); ``` ### Outgoing Call ```javascript // User initiates call InCallManager.start({ media: 'audio', ringback: '_BUNDLE_' }); // Callee answers InCallManager.stopRingback(); // ... call in progress ... // Call ends InCallManager.stop({ busytone: '_DTMF_' }); ``` ### Event Listening ```javascript import { DeviceEventEmitter } from 'react-native'; // Listen to proximity sensor DeviceEventEmitter.addListener('Proximity', (data) => { console.log('Proximity near:', data.isNear); if (data.isNear) { InCallManager.turnScreenOff(); } else { InCallManager.turnScreenOn(); } }); // Listen to headset changes DeviceEventEmitter.addListener('WiredHeadset', (data) => { console.log('Headset plugged:', data.isPlugged); if (data.isPlugged) { // Audio automatically routes to headset } }); ``` ``` -------------------------------- ### Start Ringtone with Complex Vibration Pattern Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/configuration.md Initiate a ringtone with a detailed vibration sequence, defined by an array of milliseconds for buzz and silence intervals. ```javascript InCallManager.startRingtone('_DEFAULT_', [200, 100, 200, 100, 200]); ``` -------------------------------- ### startRingtone Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/README.md Plays a ringtone with optional vibration pattern, iOS audio category, and duration. ```APIDOC ## startRingtone(`ringtone: string, ?vibrate_pattern: array, ?ios_category: string, ?seconds: number`) ### Description Plays a ringtone. - `ringtone`: Specifies the ringtone type, either '_DEFAULT_' or '_BUNDLE_'. - `vibrate_pattern`: An array defining the vibration pattern (similar to RN, but without repeat support). - `ios_category`: (iOS only) Specifies the audio category for iOS. - `seconds`: (Android only) Specifies the duration in seconds to play the ringtone. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **ringtone** (string) - Required - '_DEFAULT_' or '_BUNDLE_'. - **vibrate_pattern** (array) - Optional - Vibration pattern. - **ios_category** (string) - Optional - iOS audio category. - **seconds** (number) - Optional - Duration in seconds (Android only). ### Request Example ```json { "ringtone": "_DEFAULT_", "vibrate_pattern": [0, 1000, 500, 1000], "ios_category": "ambient", "seconds": 10 } ``` ### Response #### Success Response (200) No specific response body documented. ``` -------------------------------- ### Start Proximity Sensor Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/api-reference/InCallManager.md Activates the proximity sensor to detect user proximity to the device screen. Triggers a 'Proximity' event. Supported on Android and iOS. ```javascript InCallManager.startProximitySensor(); ``` -------------------------------- ### Play Ringtone for Incoming Call Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/START-HERE.md Use this snippet to play a ringtone when a call comes in and stop it when the user answers. It also starts the call session. ```javascript import InCallManager from 'react-native-incall-manager'; // When call comes in InCallManager.startRingtone('_BUNDLE_'); // User answers InCallManager.stopRingtone(); InCallManager.start({ media: 'audio' }); // User hangs up InCallManager.stop(); ``` -------------------------------- ### Start InCallManager with DTMF Ringback Tones Source: https://github.com/react-native-webrtc/react-native-incall-manager/blob/master/_autodocs/configuration.md Initiates an audio call using DTMF tones as the ringback sound. This is useful for specific signaling requirements. ```javascript InCallManager.start({ media: 'audio', ringback: '_DTMF_' }); ```