I am implementing calls (one-on-one and group) on ...
# ask-ai
l
I am implementing calls (one-on-one and group) on a (React Native) Expo app, with its custom native code generated. I've been able to achieve some milestones, but some core challenges remain. One of the challenges is receiving call notification (full UI display & push notification) when the app is in the background or terminated state. I've only been able to render a full UI call notification display when the user is active on the app. Secondly, for a one-on-one call, when one party ends the call, it does not end immediately on the other party's end; sometimes it doesn't end at all until the app is terminated. How do I solve these issues?
t
Thanks for reaching out, A.. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I completely understand the challenges you're facing, and I'm here to help you through them: 1. Receiving call notifications when the app is in the background or terminated: To make this happen, you'll want to integrate push notification services like Firebase Cloud Messaging (FCM) for Android or Apple Push Notification Service (APNs) for iOS. These services help wake the app and bring up the call UI. I know the details can be a bit tricky, and the current resources don’t cover this fully. If you could share a bit more about your backend setup or how your signaling works, I’d be happy to provide more tailored guidance. 2. Ending calls properly on both ends: Here are some steps to ensure a smooth call ending process: • Use the server-side
delete_room
API to explicitly delete the room when a call ends. This helps disconnect all participants and triggers the
Disconnected
event on the clients. • On the client side, make sure to listen for the
RoomEvent.Disconnected
event so you can clean up the local state and update the UI accordingly. • Enable logging to keep an eye on disconnection reasons, which can be really helpful for debugging. • Handle temporary network hiccups by using the
Reconnecting
and
Reconnected
events to tell the difference between brief interruptions and final disconnections. Please don’t hesitate to reach out if you want me to walk you through any of these steps or if there’s anything else you’d like to clarify. I’m here to support you! Sources: index.tsx | example/src/RoomPage.tsx | Community & Support | livekit/livekit_composite | DeepWiki | Agents telephony integration | LiveKit Docs | Connecting to LiveKit | LiveKit Docs
l
Firstly, I would like you to walk me through the "*Receiving call notifications when the app is in the background or terminated"* solution. Unfortunately, I don't have access to the backend implementation; my work is only on the frontend
t
I totally understand how important it is to have call notifications working smoothly, even when the app is in the background or closed. Usually, this involves some backend support to send push notifications through Firebase Cloud Messaging (FCM) for Android or Apple Push Notification Service (APNs) for iOS. Without access to the backend, it can be a bit tricky to get this fully working. But don’t worry, there are a few alternative options you might consider: • Foreground Services (Android) and CallKit (iOS): These tools help keep a persistent connection and show the call UI when the app is running or in the background. However, they can’t wake the app if it’s completely closed without push notifications. • WebSocket or Polling Mechanism: If you have access to a signaling server or can set up a persistent WebSocket connection, your app can listen for incoming call events while it’s in the foreground or background. This still requires some backend signaling, though. I know it’s frustrating that without backend access, fully implementing push notifications for calls when the app is terminated isn’t possible. But I’m here to help! If you want, I can guide you through setting up foreground services or CallKit to handle calls when the app is active or in the background. Just let me know how I can support you! Sources: src/LKNativeModule.ts | app.json