The end of ghost calls on iPhone thanks to Flexisip 2.2!

Primary tabs

This article does not talk about phone spam, or any abnormal performance of Flexisip, but the subject is about the resolution of a problem that appeared a few years ago due to an evolution of Apple platforms.

The problem with mobile devices

Most of the SIP proxies started their development by targeting mainly so-called "fixed" devices, meaning devices that are always connected to the Internet and especially not having any problem of power consumption on which the Linphone application is always running. In this case, when calling a user, the proxy would try to route the call to all the contact addresses known for the user. If there was no answer, the system would conclude that the user was offline.

However, this system is not compatible with mobile devices. Why not? It is often the case that a user will be "online" without starting the application on their phone. In some cases, smartphones also cut off, or may not allow, applications to run in the background (for energy saving purposes). The problem is then that the user is identified as "offline" by the proxy, which will have to find another solution to transmit the call.

The arrival of push notifications, a solution for mobile devices 

Mobile OS designers then offered web APIs to allow the developer to send push notifications to a user's smartphone, either to display messages to the user (message push), or to wake up the application and transmit information (background push or silent push).

It was these push notifications that solved the problem of an unreachable mobile. When a call is made, Flexisip tries to contact the different devices owned by the user, and if it sees that the user has a mobile device it will use a push notification service to send a (background/silent) push so that the mobile device will reconnect. In this case, even if all the devices seem to be offline, the proxy will hold the call for a while, waiting for the device to reconnect when it receives the push notification.

If the call is picked up/hung up/cancelled by another device before the mobile device received the push, the mobile device will connect again, but no call will be transmitted and no notification will be displayed. A silent push notification is sent, and only the reception of the call by the application will trigger ringing or a notification.

Limitation of "silent push" by Apple

In order to reduce the background usage of applications, Apple has limited the number of silent push notifications, forcing us to send VoIP pushes when a call is made. The disadvantage of this type of push is that it triggers the phone to ring. If the user picks up the call on the phone, there is no problem, but in the case where the user picks up/hangs up/cancels the call from another device, the push notification will still trigger ringing, and Linphone will not receive INVITE and/or CANCEL messages because the call will have already been destroyed by the proxy.

For users of Apple smartphones, this could be quite annoying, as their device would ring despite the fact that they had already rejected the call or the caller had ended the call.

Saving the context of the call during Apple push

To overcome this, Flexisip proxy now stores the call information (the INVITE and CANCEL requests) even after the call is over, in order to wait for reconnection of the user's different devices. This is unlike the previous process, which involved the automatic deletion of the call in the proxy once it had been picked up/hung up/cancelled via another device. 

Thus, as soon as a VoIP push is received that makes the device ring, it will be able to re-register and receive an INVITE+CANCEL message directly, which will have the effect of stopping the ringing and adding an entry to the call log. 

Gone are the days of ghost calls, due to a push that arrives after the call has ended!