Android receives a Firebase data push, and your app shows a call screen. iOS receives a PushKit VoIP push through APNs, and the SDK shows it on CallKit: see iOS: PushKit and CallKit. The claim, the answer and the call are the same on both.
How it works
- A call rings a SIP user whose app isn’t connected. Vobiz holds the call for up to 30 seconds and pushes every device registered for that SIP user.
- Your app receives the push, shows a call screen, and hands the push to the SDK with
handleIncomingPush. - The SDK claims the call: its next REGISTER carries the push’s hold reference, and Vobiz sends the held call to this phone.
- The call arrives as a normal incoming call. If the user already tapped Accept, the SDK answers at once.
Before you start
- Android: Firebase. Create a Firebase project, add your Android app, put
google-services.jsoninandroid/app/, and addfirebase_coreandfirebase_messagingto your app. - iOS: an APNs key. In the Apple Developer portal, turn on Push Notifications for your app’s App ID, then create a key under Keys with Apple Push Notifications service (APNs) and download its
.p8file. Note the key ID and your team ID. An Apple Developer Program membership is required. - Vobiz push credential. In the Vobiz Console, open Voice > Push Notifications and add a credential for your app’s package name (Android, the Firebase service account) or bundle ID (iOS: the
.p8key, key ID and team ID). Vobiz sends incoming-call pushes with it. For iOS, add one with Sandbox on for builds you run from Xcode, and one with it off for TestFlight and the App Store. - A call screen. A plugin such as
flutter_callkit_incomingshows the full-screen incoming-call UI on a locked phone. See the manifest changes it needs. - A SIP user to push. Pushes target the SIP username the app signs in as (
client.sipUsername).
Register the device
Register the phone with Vobiz after the user signs in, and again whenever its push token changes. Remove it at sign-out.Signature
register sends POST https://api.vobiz.ai/api/v1/devices/register, and logout sends DELETE https://api.vobiz.ai/api/v1/devices/logout. Both throw VobizException (push_device_failed) with Vobiz’s message when the request is refused.
Stay reachable after Android closes the app
The SDK registers for an hour at a time (Expires: 3600) and renews while the app runs. When Android closes the app without signing out, Vobiz keeps the registration until it expires, and calls in that time take the push path. Each time the user opens the app, the SDK registers again for another hour.
A sign-out with client.disconnect() removes the registration, so call devices.logout too: a signed-out phone shouldn’t ring.
Receive the push
VobizIncomingPush.tryParse reads a push’s data map, such as RemoteMessage.data. It returns null for anything that isn’t a call push.
Signature
handleIncomingPush starts the claim. Signed in and registered, the claiming REGISTER goes at once; otherwise the next sign-in carries it, so sign in right after. It returns false and does nothing for a push that isn’t a call Vobiz holds, is a test, or has expired. The same push handled twice returns true and does nothing more.
A Vobiz push looks like this (Firebase delivers every value as a string):
Foreground and background
Handle the push in both places Firebase delivers it:Accept or decline from the call screen
Report the call screen’s buttons to the SDK. A call accepted, or declined, before it arrives is answered, or declined, as soon as it does.Signature
When the user taps Accept while the app is closed, Android opens it. Hand the accepted push to the SDK before you sign in, so the sign-in’s REGISTER claims the call:
iOS: PushKit and CallKit
On iOS, Vobiz sends an APNs VoIP push (topic<bundle ID>.voip, 30-second expiry) to devices registered with platform: 'ios'. The SDK handles it natively (from vobiz_webrtc 0.3.0):
- registers for PushKit at launch, so a push can wake a closed app
- reports every push to CallKit before iOS’s deadline (iOS terminates an app that doesn’t)
- shows the CallKit call screen, also on a locked phone
- starts the call’s audio only when CallKit activates the audio session, so a call answered on the lock screen isn’t silent
- claims the held call, and turns CallKit’s Accept, Decline, End, mute and hold into SDK calls
flutter_callkit_incoming or any Swift of your own on iOS.
If your app copied the Swift from the
vobiz_webrtc 0.2.x example, remove it when you upgrade, together with any iOS use of flutter_callkit_incoming. Two CallKit integrations in one app show every call twice.Project setup
- Capabilities. Xcode > Runner > Signing & Capabilities: add Push Notifications. In
Info.plist,UIBackgroundModesgetsaudioandvoip(see Installation). - AppDelegate. A push launches a closed app in the background, without a window, so the Flutter engine must start in the AppDelegate. Make it a
VobizAppDelegate:
AppDelegate.swift
- SceneDelegate (Flutter 3.38 and later, with window scenes). Show the AppDelegate’s engine, and remove
UISceneStoryboardFilefrom the scene configuration inInfo.plistso the scene doesn’t start a second engine:
SceneDelegate.swift
Start iOS push in Dart
StartVobizIosPush once, before signing in, so the push that launched the app is claimed by that sign-in. Sign in when a push arrives while the app is signed out.
Signature
Register with the VoIP token
Follow the pushed call
pushCallUpdates reports each step of a pushed call:
Each
VobizPushCallUpdate has push, status, and callId (the SDK’s call ID once the call has arrived).
client.isPushedCall(callId) tells you whether an incoming call came through push, and client.pushedCall returns the push being handled.
Test push-to-wake
- Sign in on a real Android phone and register the device.
- Close the app without signing out:
client.disconnect(unregister: false)simulates Android closing it. - Call the phone’s SIP user, for example with the Voice API to
sip:YOUR_SIP_USERNAME@registrar.vobiz.ai, or a number whose application dials<User>. - The call screen should appear within a few seconds. Tap Accept.
- Use a real iPhone (the simulator doesn’t receive VoIP pushes) with a profile or release build:
flutter run --profile, or set Xcode’s Run scheme to Profile. A debug build can’t start without Xcode attached and crashes when a push wakes it. - Use a Sandbox credential in the Console for builds from Xcode or
flutter run, and a production one for TestFlight and the App Store. - Sign in, register the device, then swipe the app away and call its SIP user. CallKit’s incoming-call screen should ring within a few seconds.
Limits
- iOS outgoing calls aren’t on CallKit. They run in the app, kept alive in the background by the
audiobackground mode. - 30-second hold. If the app can’t claim the call in time, the caller hears the call fail.
- Device registration credentials. Vobiz’s device API takes account credentials today; register devices from your backend in production.
- One registration per SIP user. Give each phone its own SIP user: the newest sign-in replaces the previous one.