skip to Main Content

I built a VoIP calling app which maintains a persistent connection with the server to listen to any incoming calls. I implemented a background service to do this.

But since Oreo, this running code is now broken because of the introduction of Background Execution Limits

After looking into forums, I found that some people are suggesting

  1. Convert Service to JobService and let android schedule it

    Doing so, my app won’t be able to receive calls when it is stopped

  2. Run your operations in foreground services

    It is annoying for some users to see a constant notification in the notification bar. So these above-mentioned options aren’t working for me to fix my code for Oreo.

How does WhatsApp get the incoming (VOIP) call in Android (Oreo onwards) working around the Background Execution Limits?

3

Answers


  1. There are two options:

    • use platform push services (APNS or FCM)
    • maintain persistent socket connection and exclude application from battery optimisations.
    Login or Signup to reply.
  2. (Sticky) foreground services are not affected by the restrictions. So you could use one those as replacement for background services on Oreo.

    But foreground services have two disadvantages: They are less likely killed by the system in order to reclaim resources compared to background services, and hence affects the Android system’s self-healing capability. And they require you to display a permanent notification. But Users are able to suppress the notification, somewhat mitigating this disadvantage.

    Login or Signup to reply.
  3. I am assuming that you are using SIP to establish the connection and initiate calls. Without a service constantly re-sending REGISTERs, the app doesn’t receive INVITEs when the server sends them.

    A workaround for this problem is what is called the “push notification strategy”. It works as follows, when the server sends a INVITE, it also sends an FCM notification to your app, This wakes up your app which then sends a REGISTER to your server, which in return forks the call to your app. Here is a video that better explains this strategy

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search