Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to stay on in background? #55

Closed
singpolyma opened this issue Apr 19, 2017 · 51 comments
Closed

How to stay on in background? #55

singpolyma opened this issue Apr 19, 2017 · 51 comments

Comments

@singpolyma
Copy link

singpolyma commented Apr 19, 2017

I cannot get this app to stay running in background. Whenever I swipe it closed, the service stops and I get no incoming calls.

Background mode is checked. I tried unchecking "doze mode" but then the app crashes when I swipe it closed.

Any ideas?

I am on a Nexus 4 running Android 5.1.1

@DatBewar
Copy link
Contributor

Hello,
Thanks for reporting the crash with Doze mode it's fixed now:
9754923
Concerning the background mode, currently this is the push notification which wake up Linphone.

@singpolyma
Copy link
Author

So, how do I get it to stay on in the background without push, since my server doesn't support push notifications?

@DatBewar
Copy link
Contributor

DatBewar commented May 2, 2017

Currently you can't stay in the background without push. I don't know if we will change this in the future.

@pete-gh
Copy link

pete-gh commented May 20, 2017

So I have push enabled, disabled doze mode, but after swiping the app away, I don't get incoming calls. What else can I do?

@singpolyma
Copy link
Author

@pete-gh push won't actually work with any but their server. We need to add real background support, it seems.

@keverets
Copy link

CSipSimple stays registered in the background. Has any investigation been done to see how CSipSimple accomplishes it, but linphone does not?

@pete-gh
Copy link

pete-gh commented May 21, 2017

@singpolyma Indeed it does.
@keverets The only issue I have with CSipSimple, it's ugly and hasn't been updated in 3 years. It does indeed stay in the background though, same as Fongo does, hoping Linphone can do the same one day; both apps stay in the notification bar, even after swiping away the app.

@JurateT
Copy link

JurateT commented Jul 27, 2017

If app was closed, first push notification starts service, but unfortunatelly, no call is received. So second call is needed. I guess call information should be read from push notification.

@keverets
Copy link

@JurateT my phone does not have google services, so no GCM for push messaging. Linphone should be able to work similarly to CSipSimple & Fongo and stay open in the background (likely with a service) without needing a nudge from a push notification.

@devurandom
Copy link

I would need background mode to work with sipgate. Can I point them to some document that explains to them how they would need to configure their servers for this to work?

@bkuhls
Copy link

bkuhls commented Aug 6, 2017

@v-fox
Copy link

v-fox commented Sep 23, 2017

Currently you can't stay in the background without push. I don't know if we will change this in the future.

Kudos to you for not abandoning F/OSS SIP efforts on Android but this is really irresponsible. I can't persuade 2 of my friends to use Linphone because "this stupid app kills itself". Not to mention that all this "push" crap is just another trojan tactic from Google. We didn't buy >4000mah & 3Gb phones to do something like that. Could you just make a checkbox to disable suicide code from LinphoneService.java ?

Another big turn off is the lack of amplification controls (for some reason, in LP and only LP my BT headset is 5 times quieter than normal) and codec priority. Small one is the lack of auto-recording but that's another matter entirely.

@zgmunshi
Copy link

zgmunshi commented Oct 2, 2017

There are couple of ways to receive incoming calls if app is killed or screen is locked;

  1. The old way,keep the background service enabled so that it will keep on residing in your notification center.
    Doing that is really simple as by default it is disabled in latest version of android, you don't need to comment or modify any code,just go to "res/values/non_localizable_custom.xml" and find "kill_service_with_task_manager" and set its value to false. Recompile and build the app, linphone service will be always running.

  2. The new as said by Linphone,Push way. What you need to do is just make simple push notification to the device once call is made, the catch you need to make "data message" push not notification message to make it working.

Regards,
Zeeshan.

@CodingFanatic-zz
Copy link

Just a minor correction to zgmunshi's comment above. By setting the "kill_service_with_task_manager" to false (instead of true) and recompiling, the linphone service stays up.

@herbsmn
Copy link

herbsmn commented Dec 10, 2017

LinPhone should turn this into a setting option instead of requiring users to recompile the app in order to get it to stay on in the background. There's a lot of Android users that hate Google's proprietary push notifications and it off of their phones. These users should be able to use vanilla LinPhone without having to recompile the app.

@herbsmn
Copy link

herbsmn commented Dec 10, 2017

Update: F-Droid is planning on doing the "kill_service_with_task_manager" set to false thing for their version of the build. https://gitlab.com/fdroid/fdroiddata/issues/1029

@whitetornado
Copy link

any news about this update?

@juha-h
Copy link

juha-h commented Apr 25, 2018

Requiring push in order to stay in the background is a very unfortunate decision. Please make it configurable in Settings.

@czaviar
Copy link

czaviar commented May 28, 2018

Setting "kill_service_with_task_manager"=false does not have any effect on Android Oreo. Android 8 prevents Linphone REGISTER messages when screen is off. The standby scenario is as following:

  1. Once I make screen OFF, Linphone keep sending REGISTER messages during the first 1 hour (every 10 min when reg_expire=600).
  2. After first 1 hr the following message is being sent ca. 60 mins after.
  3. After the 2hrs the following messages are sent every 6 hours.
  4. Once I make screen ON, REGISTER is sent immediately.
  5. When the phone is charging the REGISTER messages are sent every 10 mins no matter if the screen is ON or OFF.

@juha-h
Copy link

juha-h commented Jun 13, 2018

It is now impossible on Android O upwards to keep application running and accessing the network when it is not the one that is currently interactive? Could you czaviar give my Android baresip app https://github.com/juha-h/baresip-studio a try and tell what happened? It stays registered as long as I don't quit it on my Android 5.1 and 7.1 devices. baresip apk is also available here: https://box.tutpro.com/tmp/baresip.apk.

@GrahamJB1
Copy link

If you turn on linphone Settings: Advanced: Enable Service Notification, then use the android Notifications linphone app control to not show the banner, as well adding Linphone to Device Maintenance: Battery: Unmonitored Apps to keep the app running you may have better luck on O.
The banner, even if not visible, seems to have a big effect.

@Viish Viish closed this as completed Nov 12, 2018
@bharathikrify
Copy link

onMessageReceived not calling in Firebase service when app is in background

@bharathikrify
Copy link

Linphone calls are not working when app in background .
I am using push notiifcations but the method onMessageReceived()
is not triggered when my app is in background.
Any ideas?
Thanks in advance

@Viish
Copy link
Member

Viish commented Dec 4, 2018

@bharathikrify Do you have a google-services.json file in your project that match the proxy server your are connecting to ?

@Viish
Copy link
Member

Viish commented Mar 22, 2019

So your problem isn't push related.
I can be your client doesn't receive the INVITE from the server (or the server doesn't send the INVITE correctly).

@gopipeddisetti
Copy link

Hello Viish,
Here is my invite request please correct me if i am did any mistake

INVITE sip:666@192.168.75.24:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.2.17:56009;branch=z9hG4bK.vjSn0tipX;rport
From: sip:50004@192.168.75.24;tag=t~kW7ghZU
To: "666" sip:666@192.168.75.24
CSeq: 20 INVITE
Call-ID: RyYoAOWdho
Max-Forwards: 70
Supported: replaces, outbound, gruu
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, UPDATE
Content-Type: application/sdp
Content-Length: 494
Contact: sip:50004@192.168.75.168:36932;app-id=885336110466;pn-type=firebase;pn-tok=ejirqBZAGkQ:APA91bGnpYabdj_-LPaDNK31DN4g4qv-pINllcG5Z-p_d9W3LOY3Hl9AJyiS1XZVXdt-VbAHlSc6gD_8Zzd42cCuXB6fBqE3xj_VVeKbs1viZ50WSsSFbyEKAULU73UkoryFJSz-F46J;pn-silent=1;transport=udp;expires=300;+sip.instance="urn:uuid:768ad726-eecd-007c-833f-eff31ec2a637";+org.linphone.specs=groupchat
User-Agent: LinphoneAndroid/1.0 (belle-sip/1.6.3)

v=0
o=50004 1824 3396 IN IP4 192.168.2.17
s=Talk
c=IN IP4 192.168.2.17
t=0 0
a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics
m=audio 7076 RTP/AVPF 96 97 98 0 8 18 101 99 100
a=rtpmap:96 opus/48000/2
a=fmtp:96 useinbandfec=1
a=rtpmap:97 speex/16000
a=fmtp:97 vbr=on
a=rtpmap:98 speex/8000
a=fmtp:98 vbr=on
a=fmtp:18 annexb=yes
a=rtpmap:101 telephone-event/48000
a=rtpmap:99 telephone-event/16000
a=rtpmap:100 telephone-event/8000
a=rtcp-fb:* ccm tmmbr

send 288 bytes to udp/[192.168.75.168]:36932 at 18:47:22.252736:

SIP/2.0 100 Trying

@Viish
Copy link
Member

Viish commented Mar 22, 2019

I think your issue come from the fact you are using UDP which is highly unreliable.
Try TCP or even better TLS and it should work just fine.

@GrahamJB1
Copy link

GrahamJB1 commented Mar 22, 2019 via email

@Viish
Copy link
Member

Viish commented Mar 22, 2019

We're not discussing an app killed issue, but the fact he doesn't receive it's INVITE.
If push is received, app is woken up and a new socket is created to the server. At this time the server is supposed to send the INVITE to the device, but it appears the device doesn't receive it.
This can be caused by the UDP protocol and thus could be fixed by TCP/TLS.

@brianjmurrell
Copy link

I doubt UDP is as unreliable as you are making it out to be.

@gopipeddisetti
Copy link

I think your issue come from the fact you are using UDP which is highly unreliable.
Try TCP or even better TLS and it should work just fine.

Thanks it's working.

@gopipeddisetti
Copy link

gopipeddisetti commented Apr 4, 2019

i am using Oreo when app kills from background i didn't get the incoming call,how i will get incoming call when app killed.

@GrahamJB1
Copy link

GrahamJB1 commented Apr 4, 2019 via email

@Viish
Copy link
Member

Viish commented Apr 5, 2019

You have two ways to stay in "background": either set a foreground notification on the LinphoneService so it won't be killed (service notification in the advanced section of the settings) or use push notifications (which is better) to wake up the app when an call or chat is received.

@GrahamJB1
Copy link

GrahamJB1 commented Apr 5, 2019 via email

@Viish
Copy link
Member

Viish commented Apr 5, 2019

@GrahamJB1 I disagree, using push notifications there is absolutely no issues to receive a call or a message at any time.
Furthermore, the doc says that a for Android 9, if the app runs a foreground service it will be categorized in the active bucket: https://developer.android.com/about/versions/pie/power

@GrahamJB1
Copy link

GrahamJB1 commented Apr 5, 2019 via email

@GrahamJB1
Copy link

GrahamJB1 commented Apr 5, 2019 via email

@SafeSoft-tlt
Copy link

SafeSoft-tlt commented Jul 30, 2019

Works on Android 8.1 (did not check on Android 9):
https://play.google.com/store/apps/details?id=ltd.gmobile
Disable push notifications in the settings. The application intercepts the transition to Doze mode and wakes up the device.

In the Android settings, the application should be allowed not to save battery!

Who will check on Android 9 please report.

@brianjmurrell
Copy link

@SafeSoft-tlt
Copy link

@GB8994
Copy link

GB8994 commented Nov 1, 2019

I am also able to integrate it successfully and able to receive a call when the app is in the foreground. But issue occurred when the app is forced closed from Mobile recent tabs, I am not able to receive any call in-app. I have searched for it and also added my google-service.json file as well. and also try by setting the "kill_service_with_task_manager" flag to false in res/values/non_localizable_custom.xml file. But still no luck.

Also attached here my log file here: https://tinyurl.com/yxbuv7w6

@arifinjaz
Copy link

Hi Guys,

For people who are non-technical.
Just go to the background setting or battery settings of your phone and make an exception for this app for high power consumption.
I did it and it is working fine for me.
I'm using Vivo V15.
#WFH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests