Configuring push notification
Configuring push notification
If you have a mobile phone and you have developed your own softphone application, you may need to trigger a push notification to wake up your mobile application to be able to get your call. When you are dialing an extension and you have activated the "Push notification" checkbox, the script at /var/lib/asterisk/agi-bin/pushnotification.php is triggered. You can't customize directly the pushnotification.php script or otherwise it will be overwritten at each MiRTA PBX upgrade, instead you need to create a /var/lib/asterisk/agi-bin/pushnotification-custom.php script contaning at least a function like:
function pushnotification_custom($tenantid,$peername) { ... }
The parameters will be the id of the tenant and the extension name, like 100-DEVEL. Nothing is expected in return. You pushnotification_custom function will do the real push notification.
If you need to wait until the extension is online, you can add the following code to your function:
$dbpeername=$dbconn->qstr($peername); $steps=0; while ($steps<30) { $sql="select * from st_states where st_extension=$dbpeername"; $rs=$dbconn->Execute($sql); $agi->verbose("Extension is in ".$rs->fields['st_state']); if ($rs->fields['st_state']!='NOT_INUSE') { sleep(1); $steps++; } else { break; } }
Don't forget to use a global $dbconn command to inherit the database connection.