App in background sound disappears

https://github.com/evollu/react-native-fcm/pull/496 i use this and it’s show notification, but still sound disappears after 20 seconds. I installed the react-native-callkeep library and tried to implement the codes according to the example here https://github.com/wazo-pbx/wazo-react-native-demo but did not work. I’m having trouble understanding this structure because it’s not exactly the same with this sample https://github.com/oney/RCTWebRTCDemo

i think android kills the services we call with ThreadUtils.java .
i wanted to open an issue because may be other people already solve this problem and they can help

showLocalNotification(notif) {
FCM.presentLocalNotification({
id: new Date().valueOf().toString(), // (optional for instant notification)
title:notif.title, // as FCM payload
body: notif.body, // as FCM payload (required)
show_in_foreground: true ,
ongoing: true

});

}

pc.onaddstream = function (event) {
/…/
RNCallKeep.startCall(this.getCurrentCallId(), null); //Rn callkeep
showLocalNotification(notif)
/…/
}
function leave(socketId)
{
/…/
RNCallKeep.endCall(this.getCurrentCallId());
this.currentCallId = null;
/…/
}

i don’t use callkeep myself, so feel free to open an issue and hopefully someone can help.

I tested jitsi meet and it’s working in background perfectly. Is it Developed with React Native? if it is how does it work in the background. Is there any code can take as an example?

Thank you for interest.

Yes, Jitsi Meet is developed with RN and it uses this very plugin. It does nothing special to run in the background. We do use this plugin so JS timers work in the background: https://github.com/ocetnik/react-native-background-timer

I tried using background Timer but still i am losing the connection. Are you guys using this plugin in different way

We are using the plugin to globally patch setTimeout / setInterval, because otherwise JS timers don’t run when the app is in the background.

I’ve used it globally and the app has worked in background without a problem for 40+ minutes while the phone was in charge and i close the connection myself. I tested it again when the phone was not in charge and 12 minutes worked in the background then the sound disappeared. I re-tested the jitsi meet app and it worked for 14 minutes when the phone wasn’t charging. You also have the same problem. I think we have a problem about battery usage. I tested it on my lg g4 phone.

Thank you for your help. You helped me much. I think we are going right direction.

On Android, they changed something in Oreo (I think). By using callkeep that should be solved. CallKeep uses Android’s ConnectionServices, which Jitsi uses manually now, so that should take care of it.

My android version is 5.0 lollipop Jitsi Meet I have tested with the current version of this application. App worked without a problem in the background while it was charging but the phone was not in charge it’s worked only 14 minutes. If you are using CallKeep in Google play version of this app it’s not working. I facing this problem with my LG G4 5.0 device. I will test it another devices too.

No, the play store version hasn’t been updated yet. When you did your tests, with Jitsi, were you alone in the room?

No i open this url on my browser https://meet.jit.si/ and create a room. After creating the room i’m joining same room on my phone.

When will you release the update? Once you’ve released it, if there is no problem I’m going to try to use callkeep in my application. https://github.com/ocetnik/react-native-background-timer Will you continue to use this plugin?or you will only use a callkeep

The update should be reselased soon. Yes, wie will continue to use the plugin because otherwise JS timers don’t run in the background, which we need to keepalive.

Are you using this repo https://github.com/jitsi/jitsi-meet if it is it’t too complicated i can’t understand after the update could you share basic example of callkeep usage ?

I work on Jitsi Meet, so yeah, I am using that repo. We don’t use callkeep, however, but the same tech that callkeep uses.

I tested again with google play version of jitsi meet (19.0.2) and same problem still exists. I tried two times and the first time worked in the background for 16 minutes. Second time worked 18 minutes.

Thanks for checking! Looks like we have some investigating to do…

I have been trying to solve this problem for more than a month. I am about to go crazy. If you solve the problem, I’d be grateful if you share the solution.

Thanks for everything. Good luck.

1 Like

i wonder about your final solution after this journy

On Android you will need to use a foreground service to keep the app alive. Checkout https://github.com/voximplant/react-native-foreground-service