# App in background sound disappears

**URL:** https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43
**Category:** Uncategorized
**Created:** [February 19, 2019, 8:31am UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43 "2019-02-19T08:31:52Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Eren](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/eren/32/630_2.png) [@Eren](https://react-native-webrtc.discourse.group/u/Eren)
#### Post date: [February 19, 2019, 8:31am UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/1 "2019-02-19T08:31:52Z")

</div>

After a while the connection is disconnecting while the application is in the background. I’m testing on Android how can i prevent disconnect problem

---

<div class="post-metadata">

### Author: ![saghul](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/saghul/32/4_2.png) [@saghul](https://react-native-webrtc.discourse.group/u/saghul)
#### Post date: [February 22, 2019, 6:27am UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/2 "2019-02-22T06:27:37Z")

</div>

We have observed this problem with recent Android versions. One way around it is to use a Connec tion Service (see [https://github.com/wazo-pbx/react-native-callkeep](https://github.com/wazo-pbx/react-native-callkeep)) or an Android ongoing notification.

---

<div class="post-metadata">

### Author: ![Eren](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/eren/32/630_2.png) [@Eren](https://react-native-webrtc.discourse.group/u/Eren)
#### Post date: [February 23, 2019, 6:10am UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/3 "2019-02-23T06:10:36Z")

</div>

Could you please provide a example with [https://github.com/oney/RCTWebRTCDemo](https://github.com/oney/RCTWebRTCDemo) because i can’t understand exactly how to use react-native-callkeep or an Android ongoing notification.

---

<div class="post-metadata">

### Author: ![saghul](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/saghul/32/4_2.png) [@saghul](https://react-native-webrtc.discourse.group/u/saghul)
#### Post date: [February 23, 2019, 9:27am UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/4 "2019-02-23T09:27:10Z")

</div>

Sorry I can’t provide such example as I don’t have one.

---

<div class="post-metadata">

### Author: ![Eren](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/eren/32/630_2.png) [@Eren](https://react-native-webrtc.discourse.group/u/Eren)
#### Post date: [February 25, 2019, 3:23am UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/5 "2019-02-25T03:23:36Z")

</div>

I tried to use react-native-backgroundjob for keep app alive but it’s work only short time period like 5-10 minute. I’m really stuck this point. Can I open an issue in Github for this?

---

<div class="post-metadata">

### Author: ![saghul](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/saghul/32/4_2.png) [@saghul](https://react-native-webrtc.discourse.group/u/saghul)
#### Post date: [February 25, 2019, 10:12am UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/6 "2019-02-25T10:12:30Z")

</div>

Opending an issue won’t help. I already told you 2 ways to solve it: callkeep ir an ongoing notification. Have you tried any of them?

---

<div class="post-metadata">

### Author: ![Eren](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/eren/32/630_2.png) [@Eren](https://react-native-webrtc.discourse.group/u/Eren)
#### Post date: [February 25, 2019, 10:49am UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/7 "2019-02-25T10:49:16Z")

</div>

[https://github.com/evollu/react-native-fcm/pull/496](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](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](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;  
/…/  
}

---

<div class="post-metadata">

### Author: ![saghul](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/saghul/32/4_2.png) [@saghul](https://react-native-webrtc.discourse.group/u/saghul)
#### Post date: [February 28, 2019, 1:35pm UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/8 "2019-02-28T13:35:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Eren](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/eren/32/630_2.png) [@Eren](https://react-native-webrtc.discourse.group/u/Eren)
#### Post date: [March 2, 2019, 5:57pm UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/9 "2019-03-02T17:57:42Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![saghul](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/saghul/32/4_2.png) [@saghul](https://react-native-webrtc.discourse.group/u/saghul)
#### Post date: [March 5, 2019, 10:14am UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/10 "2019-03-05T10:14:44Z")

</div>

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](https://github.com/ocetnik/react-native-background-timer)

---

<div class="post-metadata">

### Author: ![Eren](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/eren/32/630_2.png) [@Eren](https://react-native-webrtc.discourse.group/u/Eren)
#### Post date: [March 6, 2019, 1:11pm UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/11 "2019-03-06T13:11:20Z")

</div>

![Ekran%20Al%C4%B1nt%C4%B1s%C4%B1](https://global.discourse-cdn.com/free1/uploads/reactnativewebrtc1/original/1X/94944848c1d3a669ea2f60e3dd514916271af4f4.png)

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

---

<div class="post-metadata">

### Author: ![saghul](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/saghul/32/4_2.png) [@saghul](https://react-native-webrtc.discourse.group/u/saghul)
#### Post date: [March 6, 2019, 1:12pm UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/12 "2019-03-06T13:12:52Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Eren](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/eren/32/630_2.png) [@Eren](https://react-native-webrtc.discourse.group/u/Eren)
#### Post date: [March 7, 2019, 10:21am UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/13 "2019-03-07T10:21:10Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![saghul](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/saghul/32/4_2.png) [@saghul](https://react-native-webrtc.discourse.group/u/saghul)
#### Post date: [March 7, 2019, 10:22am UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/14 "2019-03-07T10:22:44Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Eren](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/eren/32/630_2.png) [@Eren](https://react-native-webrtc.discourse.group/u/Eren)
#### Post date: [March 7, 2019, 10:35am UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/15 "2019-03-07T10:35:39Z")

</div>

My android version is 5.0 lollipop [Jitsi Meet](https://play.google.com/store/apps/details?id=org.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.

---

<div class="post-metadata">

### Author: ![saghul](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/saghul/32/4_2.png) [@saghul](https://react-native-webrtc.discourse.group/u/saghul)
#### Post date: [March 7, 2019, 10:37am UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/16 "2019-03-07T10:37:34Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Eren](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/eren/32/630_2.png) [@Eren](https://react-native-webrtc.discourse.group/u/Eren)
#### Post date: [March 7, 2019, 10:43am UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/17 "2019-03-07T10:43:40Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Eren](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/eren/32/630_2.png) [@Eren](https://react-native-webrtc.discourse.group/u/Eren)
#### Post date: [March 7, 2019, 11:09am UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/18 "2019-03-07T11:09:33Z")

</div>

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](https://github.com/ocetnik/react-native-background-timer) Will you continue to use this plugin?or you will only use a callkeep

---

<div class="post-metadata">

### Author: ![saghul](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/saghul/32/4_2.png) [@saghul](https://react-native-webrtc.discourse.group/u/saghul)
#### Post date: [March 7, 2019, 11:49am UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/19 "2019-03-07T11:49:30Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Eren](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/eren/32/630_2.png) [@Eren](https://react-native-webrtc.discourse.group/u/Eren)
#### Post date: [March 7, 2019, 12:05pm UTC](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43/20 "2019-03-07T12:05:56Z")

</div>

Are you using this repo [https://github.com/jitsi/jitsi-meet](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 ?

[Next page](https://react-native-webrtc.discourse.group/t/app-in-background-sound-disappears/43.md?page=2)
