Push notifications ( on Windows-phone Windows-phone )

« Back

Push notifications with Windows mobile

WARNING: Please upgrade to the last version before trying this.

Windows phone 8 does not allow voip applications to keep running in the background. The only way to reliably achieve incoming calls or messages is to use PUSH notifications.

 

Unfortunately this will require changes to the dialplan on your PBX or SIP PROXY, this tutorial explains how it works, if you are not managing your server yourself, please forward these instructions to your voip provider or PBX administrator to enjoy incoming calls. (Or contact Microsoft and complain about them crippling their phones).

 

When the option "use PUSH" is enabled in the zoiper for WP8 preferences, an extra header X-PUSH-URI will be sent in the SIP packets that includes a PUSH URL.

 

Example:

 

REGISTER sip:10.2.1.9:6060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 10.8.3.36:52685;branch=z9hG4bK-d8754z-a48cbc16a2db2714-1---d8754z-;rport
Max-Forwards: 70
Contact: <sip:909@10.8.3.36:52685;rinstance=0667df2a9c36ce63;transport=UDP;X-PUSH-URI=http://db3.notify.live.net/throttledthirdparty/01.00/AQEVPwmdC_zuSZiednVGrPo6AgAAAAADOwAAAAQUZm52OkE0QUNBREI0MTdBQzBCNjQFBlVTTkMwMQ>
To: <sip:909@10.2.1.9:6060;transport=UDP>
From: <sip:909@10.2.1.9:6060;transport=UDP>;tag=7b68d666
Call-ID: YTE4ZWZhMmEyYjk2ZDdjM2VkZTM5YzBlYmNmNGE4ZjQ.
CSeq: 1 REGISTER
Expires: 60
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, X-cisco-serviceuri
User-Agent: Zoiper r21941
Allow-Events: presence, kpml
Content-Length: 0

 

On an incoming call for that user, the X-PUSH-URI needs to be retrieved from the server's location database and a HTTP POST request needs to be sent to that location to wake up the application on the phone. After a few seconds the softphone will be ready to accept the incoming call.

 

The following examples shows how an incoming call for extension 1001 can be used to first send a PUSH notification to wake up or start Zoiper on the windows phone 8. After a few seconds the Zoiper softphone will register to the server and the actual call can be made to the softphone.

 

Keep in mind that for this to work, Zoiper needs to have an active registration (e.g. an expiration that is not yet expired). Zoiper will automatically set the registration timeout to a high value on exit or when moving to background, but the server needs to support this high timeout as well for this user.

 

This approach requires the use of an external script to send the actual PUSH to the microsoft servers, you can download it here.

 

Keep in mind that this example is very limited in functionality and can be extended to your needs. You could for example play a message if the PUSH message resulted in a failure because the phone is out of reach.

 

You probably also want to drop root privileges when you execute the system command.

 

Example implementation for Asterisk:*

Note: Zoiper for Windows phone will not work with Asterisk v.11 and above due to an issue not caused by Zoiper.

  We have reported the problem to Asterisk. Find a patch here, that was submitted for resolving the issue.

  We are convinced that the issue does not exist in Asterisk v.1.4

 

Save the example curl script to

/usr/bin/push.sh

and make it executable with chmod +x. Please install curl if it is not installed yet.

Now add these lines to your asterisk extensions.conf

WARNING: you need to add additional filtering to avoid specially crafted sip headers from being executed through the system command. The example is intentionally kept simple.
exten => 1001,1,Answer;
exten => 1001,n,Set(location=${DB(SIP/Registry/1001)})
exten => 1001,n,Verbose(0, getting push info ${location} );
exten => 1001,n,Set(regx="X-PUSH-URI=([0-9a-zA-Z\.\:\/\_]+)")
exten => 1001,n,Set(push=$["${location}" =~ ${regx}])
exten => 1001,n,System(/usr/bin/push.sh ${push});
exten => 1001,n,Wait(3);
exten => 1001,n,Dial(SIP/1001);

 

Example implementation for FreeSwitch

 

Save the example curl script to

 

/usr/bin/push.sh

and make it executable with chmod +x

You will need to install curl if it is not installed yet.

Now add these lines to your freeswitch dialplan logic:

 

WARNING: you need to add additional filtering to avoid specially crafted sip headers from being executed through the system command. The example is intentionally kept simple.
<action application="set" data="result=${sofia_contact(1001)}"/>
<action application="set" data="push=${regex(${result}|^(?:.*)X-PUSH-URI=(.*)|%1)}"/>"
<action application="set" data="result=${system /usr/bin/push.sh ${push}}"/>
<action application="sleep" data="2000"/>
                

... continue dialing the sip user as normal ...

 

 Example implementation for Kamalio / OpenSips / Ser:

 

Under construction