Send Voip Push Notification (Push token)


I have been working on PJSIP Ext calling. Its working properly while Application is open. But not getting the call while the application is in kill mode and in background mode. So as per the research, I found that I have to send a VOIP push notification to handle these scenarios. I have manually sent it and it’s working properly fine.

Now , I want to send dynamically through dial plan or another way if there is.

So please suggest a way how can I send a push token before call inititate using dial plan?

There is nothing inherently built in to do such a thing, but there’s dialplan applications for executing things. One being System[1] to execute an application, or an AGI[2][3] could be written.

[1] Asterisk 18 Application_System - Asterisk Project - Asterisk Project Wiki
[2] Asterisk 18 Application_AGI - Asterisk Project - Asterisk Project Wiki
[3] Asterisk Gateway Interface (AGI) - Asterisk Project - Asterisk Project Wiki

Tried to setup an AGI script in dial plan as below.

exten => s,n,AGI(/var/lib/asterisk/agi-bin/voip_pushnotification.php)

and defined the php file on the same path with following code.

#!/usr/bin/php -q

<?php error_reporting(0); ob_implicit_flush(false); require_once( "/var/lib/asterisk/agi-bin/phpagi.php"); $agi = new AGI(); $agi->verbose("Channle id:",json_encode($agi->request)); ?>

But this AGI is returning a below error.

Exception: Zend Extension /var/lib/asterisk/agi-bin/voip_pushnotification.php does not exist

Is the file executable to the user running asterisk, and is the complete path to it executable?

yes, I have given a
chmod +x /var/lib/asterisk/agi-bin/voip_pushnotification.php


sudo --shell --user=<user-running-asterisk>
/var/lib/asterisk/agi-bin/voip_pushnotification.php </dev/null

yield a clue?

Sorry did not get you?

Am I need to run this command in CLI or set it inside AGI()?

He is trying to get you to run it in a shell, but in an environment similar to that in which Asterisk would run it, so that you can see what, if any, error messages appear on standard error.

I have solved the issue. It was related to PHP.

I want to put wait in in AGI script while dial plan is executing. Like dial plan should wait for the next process until current AGI script execution not will not get completed. Something like synchronize process.

Currently, AGI is working proper but next process is being started executed without completion of AGI.

How can I put a simple wait in dialplan for in an AGI script?

Waiting for the AGI to complete is the normal dialplan behaviour! Although there is something called AsyncAGI, I don’t see how it can be asynchronous with respect to the dialplan, as only one dialplan application can run at a time.

Implemented a voip push token successfully in iOS application and calling is working proper.

But the problem is, If user receive the call immediately then it’s working proper otherwise if user receive the call after 10 to 12 seconds then call is not being connecting.

Any idea or suggestion?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.