Implementing VoIP Push in Linphone Softphone and Asterisk - part 1

Let me be straight to you :) Implementing IOS VoIP Push in Linphone and Asterisk is a headache.. and in the latest version of IOS 13 or 14 is a disaster.

Why We need Push in Softphone and how is it working?

Your app will go to the background after some time and you can receive calls. So we need to send a push to Apple Push Notification Servers that is called APN and tell apple I want to wake up my app and send calls to.

How apple knows it is you and let u send it a push? You need to log in to your apple account and do the necessary steps and create a certificate so that When you call the web service Apple knows it is you. You can find these steps on the internet easily. 

Then How Apple Knows who do you want to send a push to? That's via an ID that in every device and app is unique. so you need to have it every time you want to send a push to someone. 

so  (1) we need to call a web service from apple and (2) send a unique device token that identifies our app that in our scenario is Linphone softphone.


But how do we get a unique device token for Linphone? I don't know if our method is the best or correct method but this is how we did it. 

(1) We ran a web service and wrote a web service that can accept SIP Users and device tokens and (2) we change lin phone app code to call our web service and saves the device token in our databasae whenever the user runs the Linphone softphone.



Now we have everything we need!! Really? Now, whenever we want to send a Call to Linphone we need to send a VoIP Push first and make the app active and then send the call. we are using the Asterisk telephony system. So it's a piece of a cake to call an external script and call push script. 



1 - User2 make a call to user1
2 - We check what is the SIP User of User1 and We get device token from Webservice 
3 - We send device token to APN 
4 - Apple will wake up Linphone and Linphone will register in our asterisk
5 - Asterisk Send Calls to Linphone 

Thats it but This method will work just before IOS 13 as apple change how push notification works. In part2 I will explain how we have implemented for IOS 13 and above . 
















Comments

  1. Very interesting indeed. Is the second part of this article ready? I'm struggling with push-type iOS push messages, which trigger the phone dialer, and how to match this with the incoming SIP call (it appears as a second incoming call). Thanks!

    ReplyDelete
    Replies
    1. Hi, Actually I didnt use this method. There is an easier method using linphone flexi sip . it can send push . ofcourse you need to put your own app token in the config files

      Delete
    2. Thanks. Could you please enable debug in Flexisip and send me a working example of the message sent to the Apple push server (i.e. JSON for the header and body of the request sent)?

      Delete

Post a Comment