If you need real phone calls in your app, this is the guide I wish I'd had. Not a video widget or a chat bubble with a microphone icon. Actual calls that ring on a locked phone, appear in the native call screen, and carry audio in both directions.

It's very doable. The catch is that the SIP part is maybe a fifth of the work. The rest is getting iOS and Android to cooperate, and that's where the surprises live. I'll point them out as we reach them.

We'll cover both platforms end to end.

Step 1: Install the packages

npm install jssip react-native-webrtc react-native-callkeep \ @notifee/react-native @react-native-firebase/messaging \ react-native-voip-push-notification react-native-incall-manager 

Each of these does one thing:

jssip speaks SIP. It registers with your server, places calls, receives them, and handles the protocol.

react-native-webrtc carries the audio. jssip negotiates that a call is happening, WebRTC moves the sound.

react-native-callkeep gives you the native call screen: CallKit on iOS, Telecom on Android. This is what makes your app feel like a phone rather than a website with a microphone.

@notifee/react-native is the fallback. When Android refuses to draw a call screen, you show a full screen notification instead.

Firebase Messaging wakes the app on Android. VoIP Push Notification does the same on iOS. These aren't optional, and Step 4 explains why.

react-native-incall-manager handles speaker versus earpiece and the proximity sensor.

One thing to do before anything else runs:

import {registerGlobals} from 'react-native-webrtc'; registerGlobals(); 

jssip checks for window.RTCPeerConnection before it will accept an incoming call. Without this, every call gets rejected with a 488 and you'll spend a while wondering why. Put it at the top of your entry file.

Step 2: Tell the OS your app makes calls

Before writing any SIP code, register your app as a calling app. CallKeep does this, and it only needs to happen once at startup.

import RNCallKeep from 'react-native-callkeep'; import {PermissionsAndroid} from 'react-native'; await RNCallKeep.setup({ ios: { appName: 'My App', }, android: { alertTitle: 'Calling permission required', alertDescription: 'We need a calling account so people can reach you.', cancelButton: 'Cancel', okButton: 'OK', // Telecom asks for the phone account as soon as a call is created and // throws a SecurityException if this permission was never requested. additionalPermissions: [ PermissionsAndroid.PERMISSIONS.READ_PHONE_NUMBERS, ], foregroundService: { channelId: 'call_in_progress', channelName: 'Ongoing call', notificationTitle: 'Call in progress', }, selfManaged: false, }, }); RNCallKeep.setAvailable(true); RNCallKeep.registerAndroidEvents(); 

That selfManaged: false matters more than it looks. Setting it to true tells Telecom you'll draw your own incoming call screen. That sounds appealing until a call arrives while your app is in the background, because Android blocks a background app from launching an activity. The phone rings and nothing appears on screen at all.

Letting Telecom own the call UI is what gets you a real call screen over the lock screen, so let it.

The foregroundService block matters on Android 11 and up. Without it, the microphone is cut as soon as the screen locks, which gives you the bug where the other person can hear you but you can't hear them.

Android also needs some manifest entries:

<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" /> <uses-permission android:name="android.permission.BIND_TELECOM_CONNECTION_SERVICE" /> <service android:name="io.wazo.callkeep.VoiceConnectionService" android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE" android:foregroundServiceType="microphone" android:exported="true"> <intent-filter> <action android:name="android.telecom.ConnectionService" /> </intent-filter> </service> 

On iOS, add audio, voip and remote-notification to your background modes in Info.plist.

Step 3: Register with the SIP server

Now you connect and tell the server where to find you.

import {UA, WebSocketInterface} from 'jssip'; const socket = new WebSocketInterface('wss://sip.example.com:7443'); const userAgent = new UA({ sockets: [socket], uri: 'sip:user@example.com', authorization_user: 'user', password: 'secret', contact_uri: contactUri, // built in the next step instance_id: deviceId, // a UUID you persist, see below register: false, // we register manually once connected register_expires: 43200, // Recover faster after Android kills a backgrounded socket. connection_recovery_min_interval: 2, connection_recovery_max_interval: 30, }); userAgent.on('connected', () => userAgent.register()); userAgent.start(); 

Two of those options are worth explaining.

instance_id should be a UUID you generate once and store on the device. It identifies this particular phone, so re-registering updates your existing entry instead of creating a second one. Generate a new one on every launch and the server slowly accumulates dead copies of your app, each of which it will dutifully try to reach.

register: false looks strange, but it lets you register manually on the connected event. You usually have setup to finish first, which brings us to the most important part of this guide.

Step 4: Push notifications, or your app will not ring

This is the bit that shapes everything else.

Your app holds a WebSocket to the SIP server. Background the app, lock the phone, and Android closes that socket. In my testing it died after roughly two and a half minutes, consistently.

The obvious fix is a keep-alive ping. It doesn't work. Android suspends your JavaScript timers when the screen turns off, so the ping sleeps along with the phone. I tried holding a foreground service to keep the process at high priority, and the timers still stopped.

So you can't keep a socket alive on a locked phone. That isn't a bug you fix, it's a constraint you design around.

The way in is RFC 8599. You attach push details to your registration, the server remembers them, and when a call comes in it wakes your app with a push instead of trying a socket that isn't there. Once the push lands, going from woken to ringing takes well under a second.

Those details belong in your contact address:

const buildContactUri = (user, deviceId, pushToken) => { const params = [ 'transport=wss', `reg-id=${deviceId.replace(/-/g, '')}`, 'pn-provider=fcm', // 'apns' on iOS 'pn-prid=your.bundle.id', `pn-param=${pushToken}`, ].join(';'); return `sip:${user}@your-host.invalid;${params}`; }; 

Here's the trap. jssip has a method called setExtraContactParams() that looks like the right tool for this. It puts those parameters outside the angle brackets:

Contact: <sip:user@host;transport=wss>;expires=43200;pn-provider=fcm 

The spec wants them inside, as part of the address itself:

Contact: <sip:user@host;transport=wss;pn-provider=fcm;pn-param=abc>;expires=43200 

The two lines look nearly identical. To the registrar they mean different things, and with the wrong one it will stop pushing you entirely. Not fewer pushes, none. Build the string yourself.

One more thing: your first registration needs to already carry the push token. If you register without it and attach it later, there's a window where the server has you on file with no way to reach you. Wait for the token, then register.

Handling the wake looks like this:

import messaging from '@react-native-firebase/messaging'; messaging().setBackgroundMessageHandler(async message => { if (message.data?.type !== 'voip_wake') return; // The server is holding the call until we check back in. if (userAgent?.isConnected()) { userAgent.register(); } else { rebuildUserAgent(); } }); 

iOS works the same way through PushKit, with one rule you can't bend: every VoIP push must result in you reporting a call. Every single one. If you take a push and don't report a call, the OS watchdog kills your process, and if it keeps happening Apple stops delivering your pushes.

So report the call first, before any network request, storage read or SIP work.

Step 5: Receiving a call

Incoming calls arrive on newRTCSession:

userAgent.on('newRTCSession', ({originator, session, request}) => { if (originator !== 'remote') return; // this also fires for outgoing calls // Already on a call? Tell the caller rather than ignoring them. if (callInProgress) { session.terminate({status_code: 486}); // Busy Here return; } const callerName = request.getHeader('X-Caller-Name'); setIncomingCall({session, callerName}); // Show the native call screen when the app isn't already open. if (AppState.currentState !== 'active') { RNCallKeep.displayIncomingCall(uuid, callerName, callerName, 'generic', false); } session.on('ended', cleanup); session.on('failed', cleanup); }); 

You don't need to send 180 Ringing yourself. jssip sends it as soon as this handler returns, which is a good reason to keep the handler fast. Slow work here is dead air for the person calling.

Answering is one call, and on iOS that's all there is to it:

await session.answer({ mediaConstraints: {audio: true, video: false}, pcConfig: buildPeerConnectionConfig(), }); 

On Android, what happens around that line is critical:

// 1. Bring the app to the foreground if (AppState.currentState !== 'active') { RNCallKeep.backToForeground(); await waitForAppActive(2000); } // 2. Start the microphone foreground service await startCallForegroundService(callerName); // 3. Now answer await session.answer({ /* ... */ }); 

The reason is that answering is what calls getUserMedia(), and Android won't grant a microphone foreground service to a background app. It doesn't return an error either. It gives you an audio track that looks completely healthy and carries silence for the rest of the call. Granting the permission afterwards doesn't bring it back.

Foreground, then service, then answer. That order, every time.

Once you've answered, tell Telecom promptly:

RNCallKeep.setCurrentCallActive(uuid); 

A call left sitting in the answered state gets disconnected by Telecom, which logs "call state did not move to active in designated time". At least it tells you.

Step 6: Placing a call

This part is simpler.

const target = `sip:${number}@${domain}`; const session = userAgent.call(target, { mediaConstraints: {audio: true, video: false}, pcConfig: buildPeerConnectionConfig(), sessionTimersExpires: 1800, eventHandlers: { progress: () => setStatus('ringing'), confirmed: () => setStatus('connected'), failed: e => showError(e.cause), ended: cleanup, }, }); 

Check sessionTimersExpires against your server. jssip defaults to 90 seconds and plenty of servers require at least 1800. When they disagree, every outgoing call fails with 422 Session Interval Too Small, and jssip doesn't retry that one. It reports the call as failed right after it starts ringing.

Also, don't trust isConnected() before dialling. A socket the OS closed while you were in the background still reports itself as connected until the close event arrives. Send a fresh registration and wait for the 200 OK before letting the call out. Two seconds of checking beats dialling into nothing.

Step 7: Getting the audio to work

This is the one that will cost you the most time, because the failure is so convincing. The call connects, it rings, you answer, there's a timer counting up. And there's no sound at all.

Your phone's IP address is private, so the other side can't reach it. You need STUN to find your public address, and usually a TURN relay to actually carry the audio.

const buildPeerConnectionConfig = cfg => ({ iceServers: [ { urls: 'turns:turn.example.com:5349', username: cfg.turnUsername, // these two are the easy ones to miss credential: cfg.turnPassword, }, {urls: 'stun:stun.l.google.com:19302'}, ], iceTransportPolicy: 'all', iceCandidatePoolSize: 2, }); 

Those credentials are worth double checking. A TURN server configured without a username and password authenticates with nobody, so no relay address is found, so calls over mobile networks are silent. If your backend sends the credentials separately from the server list, make sure you're actually merging them in. Ours did, and we weren't.

Then there's how long you wait while gathering addresses. You want a timeout, because waiting for every possible candidate makes the call button feel broken. But if that timeout fires before you've found a reachable address, you'll send your private ones anyway, and the call will connect with nowhere to put the audio.

So wait for something reachable, which means a srflx or relay candidate, with an upper bound so a hopeless network still gets an answer:

session.on('icecandidate', ({candidate, ready}) => { const type = candidate?.candidate?.match(/\btyp\s+(\S+)/)?.[1]; if (type === 'relay') { ready(); // best case, send now } else if (type === 'srflx') { setTimeout(ready, 400); // workable, brief wait for a relay } // nothing reachable yet, keep gathering for a few more seconds }); 

On a fast connection you'd never see the difference. On a slow one it decides whether the call has audio, and it's where most of the "it works sometimes" reports come from.

A couple of closing notes

Two things I'd pass on above everything else.

Design for push from the beginning rather than adding it once you discover sockets don't survive. It affects how you structure registration, wake handling and call setup, and retrofitting it is considerably more work.

Test on a real device with the screen locked. Every real problem I ran into lived in the gap between "it works in the simulator" and "the phone is in someone's pocket". A passing test suite won't catch any of it.

Good luck, and enjoy the moment it finally rings.