Integrating Background Video Calling in Flutter Using Agora and CallKit

Flutter Background Video Calling Integration

In today’s fast-paced mobile ecosystem, video calling has transitioned from an added feature to a core necessity. As a leading Flutter App Development and Mobile App Development Company, Getwidget recognizes the need for seamless cross-platform video communication. Thanks to Flutter’s flexibility and the availability of tools from the Flutter Open Source Widget Library, developers now have robust options to implement video calls. However, ensuring a stable video experience while the app runs in the background presents unique challenges. This blog shows how to enable background video calling in Flutter using Agora and CallKit.

Why Background Video Calling Is Essential

Video call continuity, even when an app is minimized, is critical to user satisfaction. This mirrors the behavior of apps like WhatsApp or Zoom, allowing users to multitask without dropping the call—delivering a polished and professional experience.

Prerequisites Before Implementation

To begin this integration, ensure you have:

  • Installed the Flutter SDK
  • Familiarity with Flutter App Development
  • A working Flutter project with integrated video calling
  • Access to Agora or a similar video SDK

Step-by-Step Guide to Background Video Calling Integration

1. Select a Dependable Video SDK
This guide uses Agora due to its extensive support for background services and detailed documentation.2. Configure Foreground Service on Android
To keep the app active during background video calls, Android requires a foreground service.

Update AndroidManifest.xml:

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application ...>
    <service
        android:name=".YourForegroundService"
        android:exported="false"
        android:foregroundServiceType="mediaProjection|camera|microphone" />
</application>

Include a persistent notification to comply with Android’s background execution policies.
3. Maintain Video/Audio Streams (Android)
Start and manage the foreground service using native Android code or packages like flutter_foreground_task. This keeps the video call engine, camera, and mic active even when the app is backgrounded.

4. Set Up iOS with CallKit
Apple requires additional steps for background audio and video via CallKit:

  • Use the flutter_callkit_incoming package

Update Info.plist as follows:

<key>UIBackgroundModes</key>
<array>
    <string>audio</string>
    <string>voip</string>
</array>
  • Integrate PushKit to receive VoIP calls and notifications when the app is closed or in the background.

5. Handle App Lifecycle with WidgetsBindingObserver
Use WidgetsBindingObserver or flutter_lifecycle_aware to detect lifecycle changes and maintain call state:

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
  if (state == AppLifecycleState.paused) {
    // Maintain video/audio when in background
  } else if (state == AppLifecycleState.resumed) {
    // Restore or update call UI
  }
}

6. Test on Physical Devices
Always test your implementation on real hardware, especially for:

  • Android 13 and 14 (strict background limitations)
  • iOS 14 and above (due to VoIP restrictions)

7. Feature Enhancements
For a more polished user experience:

  • Add interactive notifications (Accept/Decline)
  • Use flutter_ringtone_player for custom ringtones

Handle call drop-offs and timeouts smoothly

Common Issues & Troubleshooting

  • Audio stops on Android 13+: Verify that the foreground service is properly initiated.
  • iOS background disconnects: Ensure CallKit and PushKit integration is correctly done.
  • Crashes on Android 14: Double-check foregroundServiceType values in AndroidManifest.xml.

Conclusion

At Getwidget, we understand the importance of delivering robust mobile experiences. Implementing background video calling in Flutter can be complex, but with tools like Agora, CallKit, and native services, it’s absolutely achievable. As a trusted Flutter App Development and App Development Company, we continuously leverage the power of the Flutter Open Source Widget Library to build high-performance, scalable apps. Make sure to test on real devices and stay current with OS-specific changes to ensure a seamless calling experience.

Frequently Asked Questions (FAQ)

1. Can Flutter support background video calling natively?
No, Flutter doesn’t support background video calling out-of-the-box. You need to integrate native features through platform channels and use plugins like flutter_foreground_task for Android and flutter_callkit_incoming for iOS to manage background processes.

2. Why does the video call stop when the Flutter app is minimized on Android?
This usually happens because Android restricts background tasks for performance and battery management. To keep the call active, a foreground service must be started with appropriate permissions and a persistent notification.

3. How does CallKit help with iOS background video calling?
CallKit allows iOS apps to integrate tightly with the native call UI, enabling calls to continue even when the app is in the background. It also works with PushKit to receive incoming call notifications when the app is closed.

4. Is Agora the only SDK that supports background video calling in Flutter?
No, other SDKs like Twilio and Jitsi may also support background calls, but Agora is preferred due to its superior Flutter support, documentation, and integration with native services.

5. Can I implement background video calling using the Flutter Open Source Widget Library?
While the Flutter Open Source Widget Library provides UI components, background video calling requires native service integration. However, these widgets can enhance the call UI (e.g., call screens, buttons) within your Flutter App Development workflow.