π Expo Integration Guide for react-native-pitel-voip-v2
This guide explains how to integrate the Pitel VoIP Calling SDK v2 (react-native-pitel-voip-v2) into an Expo application (supports Expo SDK 50 up to Expo SDK 57+, React 19, New Architecture, and Expo Router).
Expo Go is NOT supported because react-native-pitel-voip-v2 contains custom C++ (PJSIP) and native iOS CallKit / Android Foreground Service modules.
You must run the app using Expo Development Builds (expo-dev-client) or build via EAS Build.
π¦ Step 1: Install Dependenciesβ
In your Expo project root, install the SDK, Firebase modules, and Expo Development Client:
# Using pnpm (Recommended)
pnpm add react-native-pitel-voip-v2 @react-native-firebase/app @react-native-firebase/messaging @react-native-async-storage/async-storage
npx expo install expo-dev-client expo-build-properties
# Using npm
npm install react-native-pitel-voip-v2 @react-native-firebase/app @react-native-firebase/messaging @react-native-async-storage/async-storage
npx expo install expo-dev-client expo-build-properties
# Using yarn
yarn add react-native-pitel-voip-v2 @react-native-firebase/app @react-native-firebase/messaging @react-native-async-storage/async-storage
npx expo install expo-dev-client expo-build-properties
βοΈ Step 2: Configure app.jsonβ
- Place your
google-services.json(Android) andGoogleService-Info.plist(iOS) in the root folder of your Expo project. - Update your
app.jsonwith the bundle identifier, package name, Firebase file paths, and config plugins:
{
"expo": {
"name": "My VoIP App",
"slug": "my-voip-app",
"version": "1.0.0",
"ios": {
"bundleIdentifier": "com.yourcompany.app",
"googleServicesFile": "./GoogleService-Info.plist",
"supportsTablet": true
},
"android": {
"package": "com.yourcompany.app",
"googleServicesFile": "./google-services.json"
},
"plugins": [
[
"react-native-pitel-voip-v2",
{
"microphonePermission": "CαΊ§n quyα»n micro Δα» thα»±c hiα»n cuα»c gα»i VoIP.",
"incomingCallMode": "fullscreen"
}
],
[
"expo-build-properties",
{
"ios": {
"useFrameworks": "static"
}
}
]
]
}
}
react-native-pitel-voip-v2config plugin automatically injects required permissions (RECORD_AUDIO,POST_NOTIFICATIONS,FOREGROUND_SERVICE,USE_FULL_SCREEN_INTENT) intoAndroidManifest.xmland background modes (audio,voip,fetch,remote-notification) intoInfo.plist.expo-build-propertieswith"useFrameworks": "static"is mandatory for Firebase and native static library linking on iOS.
π Step 3: Run Expo Prebuildβ
Generate the native android and ios project directories:
npx expo prebuild
π€ Step 4: Verify & Complete Native Configurationsβ
After prebuild finishes, complete the following native configurations:
4.1 Android Configurationβ
-
Verify
android/build.gradle: Ensure Google Services classpath is present independencies:buildscript {
dependencies {
classpath('com.google.gms:google-services:4.4.2') // or 4.3.15+
}
} -
Verify
android/app/build.gradle: Apply Google Services plugin and ensure FCM dependencies:apply plugin: "com.google.gms.google-services"
dependencies {
// Required for Kotlin compilation of Custom Messaging Service
implementation("com.google.firebase:firebase-messaging:24.1.0")
} -
Declare Custom Messaging Service in
android/app/src/main/AndroidManifest.xml: Inside<application>, register your custom FCM receiver and remove conflicting default services:<!-- Custom Messaging Service for multiplexing VoIP Push & normal notifications -->
<service
android:name=".MyCustomMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<!-- Prevent multiple FCM receivers from conflicting -->
<service
android:name="com.pitel.voip.sdk.service.PitelFirebaseMessagingService"
tools:node="remove" />
<service
android:name="io.invertase.firebase.messaging.ReactNativeFirebaseMessagingService"
tools:node="remove" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="pitel_incoming_call_channel_v3"
tools:replace="android:value" /> -
Create
MyCustomMessagingService.kt: Inandroid/app/src/main/java/<package_path>/MyCustomMessagingService.kt:package <YOUR_APP_PACKAGE_NAME>
import com.google.firebase.messaging.RemoteMessage
import com.pitel.voip.sdk.core.PitelClient
import io.invertase.firebase.messaging.ReactNativeFirebaseMessagingService
class MyCustomMessagingService : ReactNativeFirebaseMessagingService() {
override fun onMessageReceived(remoteMessage: RemoteMessage) {
val data = remoteMessage.data
if (PitelClient.isPitelPushNotification(data)) {
PitelClient.initialize(applicationContext)
PitelClient.handleFCMMessage(applicationContext, data)
} else {
super.onMessageReceived(remoteMessage)
}
}
override fun onNewToken(token: String) {
PitelClient.initialize(applicationContext)
PitelClient.saveFcmToken(token)
super.onNewToken(token)
}
}
4.2 iOS Configuration (AppDelegate.swift)β
In ios/<YourAppName>/AppDelegate.swift, initialize CallKit & PushKit listeners before the React Native bridge launches:
Merge these SDK calls into your generated AppDelegate, preserving its superclass, Expo/React Native initialization, and bundle URL overrides. The RCTAppDelegate snippet below illustrates where the calls belong; keep the startup structure generated by your Expo version. See the iOS setup guide.
import UIKit
import React
import React_RCTAppDelegate
import FirebaseCore
import react_native_pitel_voip_v2
@main
class AppDelegate: RCTAppDelegate {
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
self.moduleName = "main"
self.initialProps = [:]
FirebaseApp.configure()
// 1. Initialize PitelVoIPDelegate before JS bridge starts
_ = PitelVoIPDelegate()
PitelVoIP.configure()
let result = super.application(application, didFinishLaunchingWithOptions: launchOptions)
// 2. Register presentation host for native Call Screen
PitelVoIP.registerCallPresentationHostProvider { [weak self] in
self?.window.rootViewController
}
return result
}
}
β‘ Step 5: JavaScript / Expo Router Integrationβ
In your root layout (app/_layout.tsx for Expo Router, or App.tsx):
import React, { useEffect } from 'react';
import { Platform } from 'react-native';
import { getMessaging, getToken, requestPermission } from '@react-native-firebase/messaging';
import { PitelVoipClient } from 'react-native-pitel-voip-v2';
export default function RootLayout() {
const client = PitelVoipClient.instance;
useEffect(() => {
const setupVoip = async () => {
// 1. Request Runtime Permissions
// Microphone on both platforms; notifications on Android 13+.
const granted = await client.requestPermissions();
if (!granted) return;
// 2. Sync FCM Token to Pitel SDK
try {
const messaging = getMessaging();
if (Platform.OS === 'ios') {
await requestPermission(messaging);
}
const fcmToken = await getToken(messaging);
if (fcmToken) {
await client.setFCMToken(fcmToken);
}
} catch (e) {
console.warn('Failed to get FCM Token:', e);
}
// 3. Attempt Auto Login with cached credentials
const autoLoggedIn = await client.autoLogin();
if (!autoLoggedIn) {
// Show your app's SIP login UI and call client.login(settings).
}
};
setupVoip();
}, []);
// Return your navigation / slot
return null;
}
On a fresh installation there are no saved credentials. Follow Authenticate SIP Extension for the required login() settings, and observe the registration listener before enabling outgoing calls.
Also complete the following push handling:
- Subscribe to
onTokenRefreshand forward each new token toclient.setFCMToken(token). Remove the subscription when its owner unmounts; see the example listeners. - On iOS, forward call-cancellation payloads to
client.handlePushNotification(message.data)throughonMessagein the foreground andsetBackgroundMessageHandlerin the background. Register the background handler once in the app entry file, outside React components. Follow the iOS token and message handling guide; see also the example entry file. Keep FCM forwarding in React Native Firebase rather than adding another handler in AppDelegate.
π± Step 6: Run & Buildβ
1. Run Local Development Build:β
# Run Android Development Build
npx expo run:android
# Run iOS Development Build (Physical iPhone required for VoIP push & CallKit)
npx expo run:ios --device
2. Build Production with EAS Build:β
# Build standalone APK/AAB for Android
eas build --platform android --profile production
# Build standalone IPA for iOS
eas build --platform ios --profile production
β Summary Checklist for Expo Developersβ
- Use
expo-dev-client(do not run via Expo Go app). - Declare
react-native-pitel-voip-v2andexpo-build-properties(staticlinkage) inapp.json. - Place
google-services.jsonandGoogleService-Info.plistat the project root and link them inapp.json. - Run
npx expo prebuildand verify native configurations. - Always test inbound VoIP calls on a physical iOS device (PushKit does not work on Simulator).