Overview
One-to-one voice and video calls in Flutter apps with voxera_calls_kit.
One-to-one voice and video calls work in every Voxera project. voxera_calls_kit brings them to Flutter apps, with ringing, answering, camera and speaker controls, and ready-made call screens.
It rings on the kit's own screen while your app is open, and on the phone's system call screen when your app is in the background or closed.
Turn calls on
Calls are on for every new project that has audio or video. To check, or to turn them off, open your project's Services tab and find the Calls card. It has one switch:
- Calls: lets apps place calls. With it off, a call is refused, and in this kit
startCallthrowscallsDisabled.
An unanswered call rings for 30 seconds before it ends as missed. A call your server gives no limit can last up to 4 hours. To decide whether each call may ring and how long it may last, let your webhook endpoint answer call.check: see Call rules from your server.
Video calls need the project's video service. Call video quality follows the project's video tier. Presence (who is online) is on for every project.
To ring a phone when your app is closed, add your Apple and Firebase credentials in the Push credentials card on the same tab. See Ringing when the app is closed.
Install
dependencies:
voxera_calls_kit: ^0.2.0Set up iOS and Android
Android: add this to android/app/src/main/AndroidManifest.xml. Without it, a call can lose the microphone and camera when the screen turns off.
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
<application>
<service
android:name="io.voxera.media.plugin.VoxeraMediaForegroundService"
android:exported="false"
android:foregroundServiceType="microphone|camera" />
</application>iOS: add NSMicrophoneUsageDescription and NSCameraUsageDescription to Info.plist, and turn on the audio background mode. permission_handler also needs PERMISSION_MICROPHONE=1 and PERMISSION_CAMERA=1 in your Podfile.
Go online
Create one controller when the user signs in, and connect it. baseUrl is your engine's address, and appId and appKey are on your project's page.
final calls = VoxeraCallController(
config: const VoxeraCallConfig(
baseUrl: 'https://your-engine.example.com',
appId: 'your-app-id',
appKey: 'your-app-key',
),
userId: 'sam',
userName: 'Sam',
);
await calls.connect();For production, pass sessionProvider instead of appKey, and have your server mint the session with your Server Secret. See Credentials and auth.
Dispose the controller when the user signs out.
Show the call screens
Put VoxeraCallHost over your whole app, so an incoming call shows on any page:
MaterialApp(
builder: (context, child) => VoxeraCallHost(
controller: calls,
child: child!,
),
);Place a call
try {
await calls.startCall('ana', type: VoxeraCallType.video);
} on VoxeraCallException catch (e) {
// e.kind: microphoneDenied, alreadyOnCall, callsDisabled, notAllowed, notConnected, ...
debugPrint('Call failed: ${e.kind}');
}Incoming calls ring on their own while the controller is connected. To build your own screens, listen to the controller and read phase, call and endReason, then call accept, decline, hangUp, setMicOn, setCameraOn, switchCamera and setSpeakerOn.
Who is online
await calls.watchPresence(['ana', 'sam']);
final online = calls.presence.value; // {'ana': true, 'sam': false}
await calls.unwatchPresence(['ana', 'sam']);Past calls
final history = await calls.callHistory(page: 1, perPage: 20);
for (final call in history) {
debugPrint('${call.peerDisplayName} ${call.isOutgoing} ${call.wasMissed} ${call.duration}');
}The newest come first, and an empty list means there are no more. A user only ever gets their own calls.
Calls and rooms in the same app
Only one call or room runs at a time. Placing or answering a call leaves the room the user is in, and joining a room ends the call. A call that only rings, is refused or is declined does not touch the room.
Next
- Ringing when the app is closed
- Call rules from your server
- Webhooks for
call.accepted,call.endedand the other call events