I need to know the Call-ID header of the outgoing leg ( Leg B) before the invite is sent to the endpoint. So I can tell the endpoint(phone) to uniquely identify the call for Push Notification.
How can I get this information either in Dialplan or in AMI?
I was not able to find Call-ID header in SIP_HEADERS() for outgoing channel because I was using gosub of called channel . It gets executed before the invite is sent to the called party so I was not receiving in SIP_HEADERS().
I had to find it out before the invite is sent to the called party so I can send Push notification with Call-ID.
Fortunately a SIP Variable SIPCALLID was getting set as I saw in debug.
[checkcallid]
exten => callid,1,Verbose( sending push)
same => n,Set(foo=${SIPCALLID})
same => n,AGI(apns)
same => n,Wait(3)
same => n,Return()
And also make sure who wish to send push in this way. Keep the qualify off for unregisterd endpoints because when qualify turned on asterisk will check the status of the endpoint if it finds unreachable it will not execute the gosub and throw message for unreachable endpoint.