Skip to main content

VoIP React Native SDK

A high-performance React Native VoIP calling library for iOS and Android, powered by PJSIP native core, Apple CallKit, and FCM/APNs push notifications.

IMPORTANT
  • Physical iOS Device Required: A physical iOS device (iPhone/iPad) is strictly required to receive and test incoming VoIP calls. The iOS Simulator cannot generate valid PushKit APNs tokens and does not support receiving VoIP push notifications.
  • Annual iOS VoIP Certificate Renewal: Apple VoIP Services Certificates (.p12) expire every 1 year. You must renew the certificate annually on the Apple Developer Portal and re-upload the new .p12 file to the Portal periodically every year to avoid VoIP push notification disruptions.

๐Ÿ“š Documentation Indexโ€‹

GuideDescription
๐Ÿš€ Quick Start Guide3-step integration using the SDK's native call screens by default.
๐Ÿ“ฑ Example ProjectRun and explore the complete React Native demo app on physical iOS and Android devices.
๐Ÿ iOS VoIP Push & CallKit SetupNative iOS configuration, PushKit APNs certificates, and AppDelegate setup.
๐Ÿค– Android Push Notification SetupAndroid FCM services, permissions, lockscreen flags, and background handling.
๐ŸŒ Web Portal GuideStep-by-step guide to configure applications & credentials on the Portal.
๐ŸŽจ Custom Call Screen Integration GuideConfigure callScreenMode: 'custom' and build custom incoming and in-call React Native screens.
๐Ÿงฉ Public React Native API ReferenceComplete consumer-facing classes, methods, types, callbacks, and platform behavior.
๐Ÿ“– Call Disconnect & Error Codes ReferenceComprehensive SIP status code lookup table & standard error messages.
๐Ÿš€ Expo Integration GuideSetup with Expo Development Builds (expo-dev-client) and config plugin.
โ“ Frequently Asked Questions (FAQ)Common architecture, iOS/Android background, CallKit, audio, and troubleshooting questions.
๐Ÿค– AI Agent Installation Guide & Test Cases1-click automated setup for AI Coding Assistants and 16 post-integration test cases.

๐Ÿ“‹ Requirementsโ€‹

  • React Native: 0.70.0 or newer (supports Paper and New Architecture)
  • Android: minSdkVersion >= 24 (Android 7.0+), Java 17 / Kotlin
  • iOS: iOS 14.0+, Microphone permission, PushKit & CallKit capabilities
  • Firebase: Safe initialization in host application (@react-native-firebase/app & @react-native-firebase/messaging)

๐Ÿ“ฆ Installationโ€‹

Add this library to your project dependencies via Git (requires GitHub access permissions to the private repository):

# Using pnpm (Recommended)
pnpm add git+https://<YOUR_GITHUB_TOKEN>@github.com/voip-sdk/react-native-pitel-voip-sdk-v2.git#v1.0.16

# Using yarn
yarn add git+https://<YOUR_GITHUB_TOKEN>@github.com/voip-sdk/react-native-pitel-voip-sdk-v2.git#v1.0.16

# Using npm
npm install git+https://<YOUR_GITHUB_TOKEN>@github.com/voip-sdk/react-native-pitel-voip-sdk-v2.git#v1.0.16

# Or using SSH (if SSH Key is configured on your GitHub account)
pnpm add git+ssh://git@github.com/voip-sdk/react-native-pitel-voip-sdk-v2.git#v1.0.16

After installation, your package.json will register the dependency, and you can import it directly:

// In package.json
"dependencies": {
"react-native-pitel-voip-v2": "git+https://<GITHUB_TOKEN>@github.com/voip-sdk/react-native-pitel-voip-sdk-v2.git#v1.0.16"
}
// In your code
import { PitelVoipClient } from 'react-native-pitel-voip-v2';

Then install native CocoaPods dependencies for iOS:

When the host links CocoaPods as static libraries, keep these module-map overrides inside the application target. RNFirebase still autolinks Firebase; do not add Firebase or FirebaseMessaging manually.

target 'YourApp' do
config = use_native_modules!

pod 'FirebaseCore', :modular_headers => true
pod 'FirebaseCoreInternal', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true

# use_react_native!(...)
end
cd ios && pod install && cd ..

โš™๏ธ Platform Configurationโ€‹

VoIP calls require native background execution and push notification handling (FCM for Android, PushKit + CallKit for iOS) to wake up the device when locked or the app is killed.

Android Setupโ€‹

  1. Google Services Configuration: Place google-services.json inside android/app/ and apply the Google Services Gradle plugin in android/app/build.gradle.
  2. Permissions & Manifest: Required audio, network, and foreground service permissions are automatically merged by the SDK via Autolinking. (Optional: declare USE_FULL_SCREEN_INTENT if using Full-Screen incoming call UI).
  3. FCM Background Service: Register your custom messaging service (MyCustomMessagingService) to delegate VoIP push payloads to the SDK.
  4. Incoming Call Presentation: Choose between fullscreen (default, with notification fallback) or notification mode.

๐Ÿ‘‰ Follow the complete step-by-step guide in Android Push Notification Setup ยท Full-Screen Intent Guide


iOS Setupโ€‹

  1. Enable Capabilities: In Xcode (Signing & Capabilities), enable Push Notifications and Background Modes (Voice over IP, Audio, AirPlay, and Picture in Picture, Background fetch, Remote notifications).
  2. Add Usage Descriptions: Declare NSMicrophoneUsageDescription and NSBluetoothAlwaysUsageDescription in ios/<YourAppName>/Info.plist.
  3. AppDelegate Initialization: Initialize PitelVoIPDelegate() and configure PitelVoIP in AppDelegate.swift (or AppDelegate.mm) before the React Native bridge starts.
  4. VoIP Certificates: Apple VoIP Services Certificates (.p12) expire every 1 year and must be renewed on the Apple Developer Portal and re-uploaded to Portal.

๐Ÿ‘‰ Follow the complete step-by-step guide in iOS VoIP Push Notification Setup


Expo Setupโ€‹

Using Expo? Follow the Expo Integration Guide to set up Expo Development Builds (expo-dev-client) and the Config Plugin (app.plugin.js).


๐Ÿค– AI-Assisted Automated Setup (Beta)โ€‹

TIP

If your team uses AI Coding Assistants (Cursor, Antigravity, Claude Code, GitHub Copilot, Windsurf), you can leverage the structured instructions in AGENT_INSTALL.md to automate all native Android and iOS configurations above and verify against the test case checklist:

@AGENT_INSTALL.md Read this installation guide and assist in integrating VoIP SDK v2 into this React Native project. Follow each phase sequentially and verify against Phase 6 test cases.

๐Ÿš€ Quick Startโ€‹

TIP

๐Ÿ“ฑ Try the Example App First!โ€‹

We recommend exploring the included example app before writing custom code. It provides clear, standalone implementations for both integration modes:

From the source workspace root:

pnpm install
cd example
cp env.ts.example env.ts # Fill in your SIP credentials & teamId
pnpm android # or pnpm ios

In the binary release package, the example uses file:.. instead of workspace:*; run npm install inside example/, then npm run android or npm run ios.


How to Use the SDK (Matching example/App.tsx Flow)โ€‹

IMPORTANT

Prerequisite: Ensure you have completed the Platform Configuration (Firebase on Android and AppDelegate on iOS) before running the JavaScript code below. Otherwise, push token registration and native incoming calls will not function.

Following the exact implementation in example/App.tsx, integration requires only 3 main steps:

1. Setup Permissions & FCM Tokenโ€‹

Request audio permissions and forward the device FCM Token to the SDK:

import { Platform } from 'react-native';
import { PitelVoipClient } from 'react-native-pitel-voip-v2';
import { getMessaging, getToken, requestPermission } from '@react-native-firebase/messaging';

const client = PitelVoipClient.instance;

// 1. Request required permissions (Mic & Notifications)
await client.requestPermissions();

// 2. Register FCM token for incoming call push notifications
const messaging = getMessaging();
if (Platform.OS === 'ios') {
// RNFirebase owns APNs registration and APNs-to-FCM token mapping.
await requestPermission(messaging);
}

const fcmToken = await getToken(messaging);
if (fcmToken) {
await client.setFCMToken(fcmToken);
}

Register the background handler once at the top level of the application entry file (before AppRegistry.registerComponent):

import { getMessaging, setBackgroundMessageHandler } from '@react-native-firebase/messaging';
import { PitelVoipClient } from 'react-native-pitel-voip-v2';

setBackgroundMessageHandler(getMessaging(), async message => {
if (message.data) {
await PitelVoipClient.instance.handlePushNotification(message.data);
}
});

2. Authenticate SIP Extensionโ€‹

Check for a saved session with client.autoLogin(), or log in with credentials matching example/env.ts.example:

// 1. Check & restore previous session (Optional)
const autoLoggedIn = await client.autoLogin();

if (!autoLoggedIn) {
// 2. Log in with full credentials (matches example/App.tsx)
await client.login({
extension: 'YOUR_EXTENSION', // e.g., '100'
password: 'YOUR_PASSWORD', // e.g., 'your_sip_password'
domain: 'YOUR_DOMAIN', // e.g., 'sip.vn'
proxy: 'YOUR_PROXY', // e.g., 'sip:proxy.vn:5061'
port: 'YOUR_PORT', // e.g., '50061'
displayName: 'YOUR_DISPLAY_NAME', // e.g., 'Agent 100'
teamId: 'YOUR_TEAM_ID', // Apple Developer Team ID (found in Apple Developer Portal -> Membership)
appMode: 'production', // 'dev' for Debug mode; 'production' for TestFlight / App Store
incomingCallMode: 'fullscreen', // Android: 'fullscreen' or 'notification'
userAgent: 'YOUR_USER_AGENT', // Optional, e.g., 'Pitel App' (default: 'Pitel VoIP React Native')
});
}

The SDK uses its native call screen by default on a fresh installation. To provide custom React Native incoming and in-call screens, set callScreenMode: 'custom' in the login settings and follow the Custom Call Screen Integration Guide. The mode is saved and restored on later logins; pass 'native' explicitly to switch a previously customized installation back to the native screen.

3. Make Outgoing Callsโ€‹

Trigger an outgoing call with client.makeCall(). In native mode, the SDK opens its pre-built native call screen automatically. In custom mode, the app shows its own call screen:

// In native mode, the SDK opens its pre-built native CallScreen.
// In custom mode, show your React Native call screen in your app.
await client.makeCall('YOUR_CALLEE_EXTENSION'); // e.g., '101'

Incoming Callsโ€‹

The SDK handles call signaling and incoming-call delivery. In native mode it also presents the native call UI. In custom mode, the app handles its React Native call UI and navigation from SDK call events; follow the Custom Call Screen Integration Guide.

  • iOS uses Apple CallKit to present incoming calls, including when the app is locked or not running. The app can show its custom in-app call screen when it becomes active.
  • Android uses the configured incomingCallMode. Full-screen presentation requires the host app to declare USE_FULL_SCREEN_INTENT and have access granted where required; otherwise the SDK falls back to an actionable notification. See the Android Full-Screen Intent guide.

Optional: Disconnect Feedback (Matching Example)โ€‹

If you want to display a Toast or Alert when a call ends (like in example/App.tsx), use getPitelCallErrorMessage:

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

client.addEventListener((event) => {
if (event.type === 'onCallStateChanged' && event.state === 'DISCONNECTED') {
const errorMsg = getPitelCallErrorMessage(event);
if (errorMsg) {
console.warn('Call ended with error:', errorMsg);
}
}
});