BACK

Keep Jitsi SDK Running Smoothly in the Background

12 min Avkash Kakdiya

Ever tried using the Jitsi SDK for building video calls and hit a snag with sessions dropping when the app’s in the background? It’s annoying, right? Well, keeping that SDK up and running in the background is essential, especially if users flip between apps or lock their screens. This guide will show you how to keep that session going strong, manage it properly, and tweak battery settings so you don’t lose those calls. Even if you’re new to building with Jitsi, don’t worry—stick around, and I’ll walk you through everything step-by-step.

Why Bother with Keeping Jitsi Active in the Background?

Mobile systems love to save power by pausing or shutting down background apps when you’re not using them. Sounds smart until your video call suddenly ends. Keeping the Jitsi SDK cranking in the background lets you lock the phone, multitask—whatever you fancy—without the call hanging up. Perfect for meetings that feel like they’ll never end, right?

When I was knee-deep in developing apps with Jitsi, people kept griping about calls dropping every time they switched apps or locked phones. Whether you’re team Android or team iOS, every platform throws its own curveballs when it comes to managing stuff in the background. Tackling these issues keeps the app’s vibe smooth and users happy.

Real-Life Example: A Telehealth App

Take this telehealth app I worked on, where Jitsi linked doctors and patients over video. Patients often needed to double-check their medications mid-call without disconnecting. Setting up the right background mode worked wonders. Docs and patients got to multitask without losing the line—everyone happy!

Enabling Jitsi Background Mode

Here’s what you need to do to keep your Jitsi SDK humming along in the background:

1. Know the Rules of the Road

Android: Post-Android 8 (Oreo), Android’s strict about background stuff to save battery. You’ve got to run foreground services and ask users nicely to whitelist your app from battery optimizations.

iOS: Apple’s iOS doesn’t love background stuff either but does allow live video/audio sessions with the right permissions.

2. Using Jitsi SDK for Background Operation

Typically, Jitsi runs in the forefront. Want it in the background?

  • Android: Use a foreground service that ties into Jitsi’s lifecycle. That way, your app looks busy to the OS, so it doesn’t get booted.

  • iOS: Enable the right background modes in the Info.plist, like ‘audio’, ‘airplay’, etc., for continued streaming.

3. Tweak Your App’s Lifecycle Handling

Make sure your app elegantly handles lifecycle events:

  • Watch out when it goes to the background (onPause on Android, applicationDidEnterBackground on iOS) to ensure sessions don’t disconnect.
  • Delay releasing resources while in the background.
  • Prep for reboots if the OS interrupts your session.

4. Adjust Battery Optimization Policies

Aggressive battery savers can still chomp down on background activities:

  • Guide users to switch off battery optimizations for your app.
  • Tackle additional steps for certain brands like Samsung that have extra management layers.

Android Step-by-Step: Keep Jitsi SDK Running

Ready to roll out background mode for Android with the Jitsi SDK? Let’s do it!

Step 1: Fire Up a Foreground Service

This service keeps your app visible with a persistent notification.

public class JitsiCallService extends Service {
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Notification notification = createNotification();
        startForeground(1, notification);
        return START_STICKY;
    }
    // Notification method omitted for brevity
}

Hook this service to the manifest and kick it off when a call starts:

Intent serviceIntent = new Intent(context, JitsiCallService.class);
ContextCompat.startForegroundService(context, serviceIntent);

Step 2: Grab a Partial Wake Lock

Hold on to a wake lock so that your session isn’t interrupted when the screen’s off.

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "myapp::jitsiWakeLock");
wakeLock.acquire();

Make sure to release that lock once the call is over.

Step 3: Exclude from Battery Optimization

Get users to exempt your app from power saving:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    if (!pm.isIgnoringBatteryOptimizations(getPackageName())) {
        Intent intent = new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
        startActivity(intent);
    }
}

Communicate why this boosts call reliability.

Step 4: Lifecycle Management

Be on top of lifecycle callbacks to ensure session continuity.

5. Test It Out

Run tests on major brands like Samsung to navigate different device behaviours.

iOS Tips: Keep Jitsi SDK Running

Got an iOS device? Here’s how you keep the app running.

Step 1: Enable Background Modes

In Xcode, navigate to enable these:

  • Audio, Airplay, and Picture in Picture
  • Voice over IP (where applicable)

This keeps the audio/video streams alive.

Step 2: Configure AVAudioSession

Ensure the audio session accommodates background audio:

try AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: [.allowBluetooth, .defaultToSpeaker])
try AVAudioSession.sharedInstance().setActive(true)

This setup keeps your audio steam from being paused.

Step 3: Optional PiP

Add Picture-in-Picture support for additional user multitasking.

Step 4: Application Lifecycle Management

Handle app lifecycle events to maintain session state with care.

Battery Settings: Optimize Performance

Even with your app on point, battery stubbornness can sneak in. Here’s how you manage:

  • Tell users how to turn off optimization features.
  • Provide clear app setup instructions for different devices.
  • Use data to discourage potentially disruptive device actions with in-app prompts.

Understanding these energy-saving trades will keep your users trusting you!

Bonus Tips and Best Practices

  • Stay on Jitsi’s pulse for SDK updates.
  • Streamline your app to keep things running smoothly in the background.
  • Update to latest SDK for possible background issue fixes.
  • Use logs to fix disconnects caused by changing app states.
  • Launch push notifications if calls risk disconnecting.

My Thoughts

Every time my projects combined an android foreground service with stellar user education on battery settings, results were solid. Call drop complaints tanked and trust elevated. For iOS, enabling audio modes multitasks the task without drama.

Safety First

Running Jitsi SDK in the background doesn’t drag extra security woes if you encrypt communications just right. Jitsi runs secure WebRTC. Update the app regularly for security patches.

Be upfront with users about why you’re using their battery. They’ll appreciate it!

Resources and Industry Norms


Wrapping Up

Keeping Jitsi SDK chugging away in the background means fewer connection dead-ends and more reliable call longevity. Follow these platform-adjusted guides, tweak battery mmanagement, and educate users—you’ll see uninterrupted sessions for days. Dive into Android services, tweak iOS configurations, and always keep testing.

If you’re looking to level up or need help locking in a seamless Jitsi SDK integration, feel free to get in touch. Your users will thank you with their uninterrupted calls!


Feel like upping your app game? Start implementing these background tips with Jitsi SDK right away. Facing hurdles? Drop back by or jump into the Jitsi dev community for some guidance.

FAQ

It involves making sure your <a href='https://jitsi.support/wiki/understanding-jitsi-basics/'>Jitsi video session</a> doesn't quit when the app isn’t open, keeping the connection stable.

By setting up the SDK and app lifecycle correctly, tweaking battery settings, and using specific background modes depending on your platform.

Yep, it does use more juice, but you can tweak settings to balance power usage and session stability.

As long as you follow security norms and encrypt communications, it's pretty safe without adding risks.

Most newer devices can, though some older or customized OS versions might limit background activities.

Need help with your Jitsi? Get in Touch!

Your inquiry could not be saved. Please try again.
Thank you! We have received your inquiry.
Get in Touch

Fill up this form and our team will reach out to you shortly

Time To Skill Up

We have worked on 200+ jitsi projects and we are expert now.

ebook
Revolutionizing Telemedicine: How Jitsi is Powering Secure and Scalable Virtual Health Solutions
View White Paper
ebook
Enhancing Corporate Communication: Deploying Jitsi for Secure Internal Video Conferencing and Collaboration
View White Paper
ebook
Enabling Virtual Classrooms: Leveraging Jitsi for Interactive and Inclusive Online Education
View White Paper