Skip to main content

Custom Call Screen API

Use this guide to configure callScreenMode: 'custom' and look up the SDK functions and events used by a React Native call screen. For the default native mode and general SDK setup, see the README.

Configuration​

Set callScreenMode in login() settings. Its type is 'native' | 'custom'; use 'custom' for a React Native call screen.

import { PitelVoipClient } from 'react-native-pitel-voip-v2';

const client = PitelVoipClient.instance;

await client.login({
extension: 'YOUR_EXTENSION',
password: 'YOUR_PASSWORD',
domain: 'YOUR_DOMAIN',
proxy: 'YOUR_PROXY',
teamId: 'YOUR_TEAM_ID',
callScreenMode: 'custom', // <- Add here: use your React Native call screen.
});

Android Manifest Requirements for Custom Mode​

When using callScreenMode: 'custom', the incoming call full-screen intent targets your host app's MainActivity. You must add the following attributes to your <activity android:name=".MainActivity" ...> in android/app/src/main/AndroidManifest.xml so Android Keyguard permits your activity to turn the screen on and display over the lockscreen:

<activity
android:name=".MainActivity"
android:showOnLockScreen="true"
android:showWhenLocked="true"
android:turnScreenOn="true"
android:inheritShowWhenLocked="true"
... >
NOTE

On OEM skins such as Xiaomi (MIUI / HyperOS), users must also ensure that the app has permissions for "Show on Lock screen" and "Display pop-up windows while running in the background" enabled in App Settings.

nativeCallScreen is a deprecated legacy field; use callScreenMode instead. For Android full-screen access and platform push setup, see the Full-Screen Intent, Android push, and iOS PushKit guides.

Example code​

The easiest and safest way to integrate a custom React Native call screen is using the built-in headless hook usePitelCall(). It automatically handles:

  • Telephony state machine (idle, incoming, connecting, connected, disconnected).
  • Cold-start & notification intent restoration (checkInitialIncomingCall).
  • Foreground, background, and lockscreen incoming call coordination.
  • Immediate CallKit answer synchronization on iOS and heads-up banner on Android.
  • Background/foreground app resume synchronization (AppState).
import React from 'react';
import { usePitelCall } from 'react-native-pitel-voip-v2';
import CallScreen from './screens/CallScreen';
import MainScreen from './screens/MainScreen';

export default function App() {
const {
isCallActive,
callParams,
makeCall,
hangup,
dismissCall,
} = usePitelCall();

// 1. When a call is incoming, connecting, or active, show your custom Call Screen
if (isCallActive) {
return (
<CallScreen
route={{ params: callParams }}
navigation={{ goBack: dismissCall }}
/>
);
}

// 2. Normal application screen
return (
<MainScreen onMakeCall={(callee) => makeCall(callee)} />
);
}

usePitelCall Hook Reference​

function usePitelCall(options?: { enabled?: boolean }): UsePitelCallResult
PropertyTypeDescription
isCallActivebooleantrue when a call is ringing, connecting, or active.
callStatePitelCallState'idle' | 'incoming' | 'connecting' | 'connected' | 'disconnected'
callParamsPitelCallParams{ remoteNumber, callerName, direction, durationSec, isAlreadyAnswered, sessionId }
makeCall(number)(number: string) => Promise<void>Start an outgoing VoIP call.
hangup()() => Promise<void>End the ongoing or outgoing call.
mute() / unmute()() => Promise<void>Mute or unmute the microphone.
hold() / unhold()() => Promise<void>Hold or resume the active call.
setAudioRoute(route)(route: PitelAudioRoute) => Promise<void>Select 'earpiece', 'speaker', 'bluetooth', or 'wiredHeadset'.
toggleSpeaker()() => Promise<void>Toggle speakerphone on or off.
sendDTMF(digits)(digits: string) => Promise<void>Send DTMF keypad digits during a call.
dismissCall()() => voidManually dismiss the call UI and reset state to idle.

Advanced: Low-Level Call Screen Functions​

Get the shared SDK instance with PitelVoipClient.instance. These functions control the call or provide state for your UI.

FunctionDescription
addEventListener(listener)Subscribe to call events. Returns a function to remove the listener.
answer()Answer the incoming call. Disable the Answer button while this request is pending; update the UI from call state events.
decline()In Android custom mode, stop the local ringtone and dismiss the device's incoming presentation without sending a SIP hangup. Your app must also close its React Native screen, as the example does with navigation.goBack(). On iOS, this ends the call through CallKit when available.
hangup()End an active or outgoing call.
mute() / unmute()Turn the microphone off or back on.
hold() / unhold()Put the active call on hold or resume it.
setSpeaker(on)Turn speakerphone on or off.
setAudioRoute(route)Select 'earpiece', 'speaker', 'bluetooth', or 'wiredHeadset'.
getAudioRoute()Read the current audio route; returns a route or null.
getAvailableAudioRoutes()Get the audio routes currently available for the call screen.
sendDTMF(dtmf)Send a keypad digit, such as '1', during a call.
transferCall(to)Transfer the active call to an extension or SIP URI.
getCurrentCall()Read the current call state when restoring an active screen.
checkInitialIncomingCall()On Android, read the incoming-call snapshot that launched the app. Returns null on other platforms; it does not answer the call.
setCallScreenMode(mode) / getCallScreenMode()Change or read the saved UI mode at runtime. mode is 'native' or 'custom'.
dismissLockscreen()On Android, clear the SDK's lock-screen display flags after the custom call UI closes.

Call events​

Handle events through addEventListener() and remove the listener when its owner is disposed.

Register the listener early, then read checkInitialIncomingCall() on Android to restore a notification/full-screen launch. If there is no incoming snapshot, use getCurrentCall() to restore a live call. A pending onIncomingCallOpened can be replayed to a newly registered listener; update the existing screen rather than opening it twice, using sessionId when available. See example routing and startup handling.

EventUse in a custom call screen
onIncomingCallRead caller details and show incoming UI while the app is active.
onIncomingCallOpenedOn Android, open or restore the custom screen when the host app is opened from an incoming-call notification or full-screen intent. isAnswered indicates whether Answer was already tapped.
onCallStateChangedUpdate the screen for connecting, active, and disconnected states. sessionId identifies the call when available.
onCallDisconnectedHandle call teardown and close the screen if needed.
onMuteStatusChanged, onHoldStatusChanged, onAudioRouteChangedKeep the corresponding controls and indicators in sync with the SDK.

On iOS, CallKit continues to provide the system incoming-call UI. The React Native screen is the app's call UI.