RTCEXPRESS DOCUMENTATION
Build real-time communication into your app
This quickstart takes you from a project credential to a test call while keeping authorization under your control.
Open API referenceBefore you begin
Create a project in the customer portal. Each project has an App ID and App Secret. The App Secret belongs only in a secure backend environment, never in a browser, mobile app, or public Git repository.
1. Issue a user token from your backend
Authenticate your user in your own system, confirm that they can enter the requested room, and then call the token endpoint using project credentials.
POST /v1/token
{ "appId": "app_…", "appSecret": "sec_…", "userId": "user_123", "roomId": "room_42" }On Node.js, the rtcexpress-server package makes this call for you (Python: pip install rtcexpress-server, see the Python server SDK):
npm install rtcexpress-server
const { token } = await rtc.createToken({ userId: "user_123", roomId: "room_42" });Return the short-lived token to the client. Do not trust a room or user ID solely because the browser submitted it.
2. Initialize and join
Register listeners before initialization. When the connection is ready, join the authorized room. Enable chat and call controls after the room-joined event.
const rtc = new RTCExpress();
rtc.on("roomJoined", () => rtc.sendMessage("Hello"));
await rtc.init({ serverUrl, appId, userId, token });
rtc.joinRoom("room_42");Use the customer portal’s Integration section for the project-specific endpoint and examples.
3. Test the actual user experience
- Use two distinct users in the same project and room.
- Test camera and microphone permission denial, reconnects, and network changes.
- Test chat, voice, and video separately on real devices.
- Record the call ID and UTC time when reporting a problem.
Push notifications: ring a phone when your app is closed
While your app is open, RTCExpress delivers calls over its live connection. When the app is in the background, closed, or the phone is locked or on silent, only Google (Android) or Apple (iOS) can wake the phone. RTCExpress asks them to do it, using credentials from your Firebase and Apple accounts.
How a call reaches a closed app
Caller taps "Call" → RTCExpress server → Google FCM / Apple APNs → Callee's phone wakes and rings
(uses YOUR uploaded key) → User accepts → app reconnects to RTCExpress
Android setup (once per app)
- Create a Firebase project at console.firebase.google.com.

Click “Create a new Firebase project”. - Add your Android app to it with your exact package name (for example
com.yourcompany.app). Downloadgoogle-services.jsonand place it in your app module folder.
Project settings → Your apps → download google-services.json. YourProject/ ├── app/ │ ├── google-services.json ← put it here │ ├── build.gradle.kts │ └── src/ └── build.gradle.kts - Add Firebase Messaging to your app: the
com.google.gms.google-servicesGradle plugin and thefirebase-messagingdependency. - Generate a server key: Firebase console → Project settings → Service accounts → Generate new private key. This downloads a JSON file. It is not
google-services.json.
Project settings → Service accounts → Generate new private key. - Upload that key in the RTCExpress console under Service management → In-app chat → Android offline push. Keep the file private. Never put it in your app or Git.

In the RTCExpress console: Add credentials → choose the service-account JSON → tick the confirmation → Save credentials. - Register each signed-in device and handle incoming calls in your app (code below).
// After the user signs in, and again in onNewToken():
FirebaseMessaging.getInstance().token.addOnSuccessListener { fcmToken ->
// POST https://api.devsquarelabs.com/v1/push/devices
// Authorization: Bearer <this user's RTC token>
// {"installationId":"<random id saved on the device>","platform":"android","token": fcmToken}
}
// In your FirebaseMessagingService:
override fun onMessageReceived(message: RemoteMessage) {
if (message.data["type"] != "rtc_call_invite") return
val expiresAt = message.data["expiresAt"]?.toLongOrNull() ?: return
if (System.currentTimeMillis() > expiresAt) return // call already ended
// Show a full-screen incoming-call UI using callId, roomId, fromUserId, callType.
// On Accept: get a fresh RTC token, init, joinRoom(roomId), acceptCall().
}
Also request the notification permission on Android 13+, and declare full-screen intent for the ringing screen. On logout, call DELETE /v1/push/devices/<installationId> so the old user's calls stop ringing that phone.
The pushes RTCExpress sends
All are FCM data messages (no visible notification of their own), so your app decides what to show. Check data.type:
rtc_call_invite: someone is calling. Fields:callId,roomId,fromUserId,callType(voiceorvideo),expiresAt(milliseconds). Show a ringing screen until it expires.rtc_call_cancel: the call stopped ringing (caller hung up, it was answered on another device, or declined). Fields:callId,reason. Stop ringing.rtc_missed_call: nobody answered. Fields:callId,fromUserId,callType. Stop ringing and add it to your missed-calls list.rtc_chat_message: a new chat message while the app is in the background (after you enable room alerts). Fields:roomId,messageId.
React Native: ring, answer and stop ringing
Tested on Android phones with the app in the background, swiped away and on a locked screen. Uses @react-native-firebase/messaging for the push and @notifee/react-native for the full-screen ringing notification. Put the background handler in index.js, so it runs even when the app is closed.
// index.js (runs even when the app is closed)
import { AppRegistry } from "react-native";
import messaging from "@react-native-firebase/messaging";
import notifee, { AndroidCategory, AndroidImportance, EventType } from "@notifee/react-native";
import AsyncStorage from "@react-native-async-storage/async-storage";
import App from "./App";
async function showIncomingCall(d) {
await notifee.createChannel({ id: "calls", name: "Incoming calls", importance: AndroidImportance.HIGH, sound: "default" });
await notifee.displayNotification({
id: `call-${d.callId}`,
title: d.fromUserId,
body: d.callType === "video" ? "Incoming video call" : "Incoming voice call",
data: { ...d, kind: "call" },
android: {
channelId: "calls", category: AndroidCategory.CALL, importance: AndroidImportance.HIGH,
ongoing: true, loopSound: true,
timeoutAfter: Math.max(5000, Number(d.expiresAt) - Date.now()),
fullScreenAction: { id: "default" },
actions: [
{ title: "Answer", pressAction: { id: "answer", launchActivity: "default" } },
{ title: "Decline", pressAction: { id: "decline" } },
],
},
});
}
messaging().setBackgroundMessageHandler(async ({ data }) => {
if (data?.type === "rtc_call_invite") await showIncomingCall(data);
else if (data?.type === "rtc_call_cancel" || data?.type === "rtc_missed_call")
await notifee.cancelNotification(`call-${data.callId}`);
});
notifee.onBackgroundEvent(async ({ type, detail }) => {
const d = detail.notification?.data;
if (type !== EventType.ACTION_PRESS || d?.kind !== "call") return;
await notifee.cancelNotification(`call-${d.callId}`);
if (detail.pressAction?.id === "answer") await AsyncStorage.setItem("answerCallId", String(d.callId));
});
AppRegistry.registerComponent("YourApp", () => App);
// App.tsx: after the app opens from "Answer"
const answerId = await AsyncStorage.getItem("answerCallId");
await rtc.init({ serverUrl, appId, userId, token: await getTokenFromYourBackend() });
// A call that is still ringing is sent to the app again as soon as it connects:
rtc.on("callInvite", (invite) => {
if (invite.callId === answerId) { AsyncStorage.removeItem("answerCallId"); rtc.acceptCall(); }
else showYourIncomingCallScreen(invite);
});
Register the device after every login with POST /v1/push/devices (above), and again in messaging().onTokenRefresh. While the app is open, the SDK's own callInvite event rings it, so you don't need the push then.
iOS setup (once per app)
On iPhone, Apple wakes the phone instead of Google, so RTCExpress needs an APNs key from your Apple Developer account. Firebase is not used for iOS calls.
- Create an APNs key: Apple Developer → Certificates, IDs & Profiles → Keys → add a key with Apple Push Notifications service (APNs) enabled. Download the
.p8file. Apple lets you download it only once, so store it safely. - Note two IDs: the Key ID is shown on the key's page. Your Team ID is under Membership details. Both are 10 characters.
- Enable push for your app: in Identifiers, open your App ID and turn on Push Notifications. In Xcode, add the Push Notifications capability and Background Modes → Voice over IP.
- Upload in the RTCExpress console under Service management → In-app chat → iOS: Bundle ID, environment, Team ID, Key ID and the
.p8file. Upload it once forsandbox(Xcode builds) and once forproduction(TestFlight and App Store). The same key can be used for both. - Register two tokens per device with
POST /v1/push/devices, using the same installation ID: the PushKit token withpushType: "voip"for calls, and the normal APNs token withpushType: "alert"for chat alerts. - Show calls through CallKit as soon as a VoIP push arrives (code below).
// Calls: PushKit token → register with pushType "voip"
func pushRegistry(_ registry: PKPushRegistry, didUpdate creds: PKPushCredentials, for type: PKPushType) {
let token = creds.token.map { String(format: "%02x", $0) }.joined()
// POST /v1/push/devices (Authorization: Bearer <RTC user token>)
// {"installationId":"<saved id>","platform":"ios","pushType":"voip","token": token,
// "bundleId":"com.yourcompany.app","environment":"production"}
}
// Incoming call push: report to CallKit immediately, or iOS stops waking your app
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload,
for type: PKPushType, completion: @escaping () -> Void) {
// payload.dictionaryPayload has type "rtc_call_invite", callId, roomId, fromUserId, callType, expiresAt
provider.reportNewIncomingCall(with: UUID(), update: CXCallUpdate()) { _ in completion() }
// On answer: get a fresh RTC token, connect, joinRoom(roomId), acceptCall()
}
// Chat alerts: normal APNs token → register with pushType "alert"
func application(_ app: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let token = deviceToken.map { String(format: "%02x", $0) }.joined()
// Same endpoint and installationId, with "pushType":"alert"
}
If the phone is switched off
A call invitation lives for 60 seconds. If the phone comes online within that time it rings. Otherwise the call expires and the caller sees it was not answered, so a phone switched on hours later does not ring for an old call.
Checklist
- Firebase project is your own, and its Android app uses the same package name as your Play Store app.
- The uploaded file is the service-account key, not
google-services.json. - Devices are registered after login and re-registered when the FCM token changes.
- iOS: the APNs key is uploaded for both sandbox and production, with the same Bundle ID as your app.
- iOS: both the VoIP token and the alert token are registered, and every VoIP push is reported to CallKit.
- Tested on a real phone with the app in the background, swiped away, and the screen locked.
- Push attempts are visible in Portal → Diagnostics. Google accepting a push does not prove the phone displayed it.
Prefer to send pushes from your own server? Subscribe to the call.ringing webhook instead, and do not enable both senders for the same device.
Diagnostics and support
Signed-in customers can search diagnostics by call ID and inspect call events, quality, push attempts, and webhook delivery. Check service status before opening a support request.