Wiki -VoIP Topics

iOS Push Notifications


This WiKi topic describes how to integrate the MizuTech iOS softphone push notification capabilities with your VoIP server.

The Mizutech iOS softphone can be configured with PushKit to receive push notifications and wake up on incoming calls.
The required configuration is described in the iOS softphone build and publish guide at the PushKit chapter.
By default the softphone can use the push proxy to handle push notification (without the need for any push support on your VoIP server).

In case if you wish to handle the push notifications on your push server, then you will need to grab the required details from the SIP signaling sent by the softphone.

The app will send the X-MPUSH header with every REGISTER request like: X-MPUSH: PROVIDER:PACKAGENAME:TOKEN.
Where:
•    X-MPUSH: is the SIP header
•    PROVIDER: a single i letter meaning apple APNS
•    PACKAGENAME: is your Apple app Bundle ID
•    TOKEN: device token obtained from Apple APNs

Example:  X-MPUSH: i:com.voip.phone:abcdef

From here your server can bind a user registration to APNS token and send push notifications to the app on incoming calls.
Once the app will receive the push notification, it will wake-up (even if it was closed or the device was sleeping before), your server might need to repeat the INVITE (after the SIP standards, the INVITE request have to repeated a few times on no answer), and once it will receive the incoming INVITE it will ring as normaly.

A typical registration request looks like this:
REGISTER sip:sip.mydomain.com SIP/2.0
Via: SIP/2.0/UDP 192.168.1.101:14501;alias;branch=z9hG4bK.edThn;rport
From: <sip:1111@sip.mydomain.com>;tag=tUgBfpF8h
To: sip:1111@sip.mydomain.com
CSeq: 2 REGISTER
Call-ID: enutmuwaynqib
Max-Forwards: 70
Contact: <sip:1111@192.168.1.101:14501>
Authorization:  Digest realm="sip.mydomain.com", nonce="WvDOe1rwzc2EDrmrsjELzwQLYnJ7tD3H", username="1111",  uri="sip:gw.mydomain.com", response="1336341b517678240fb092e0cf1159a7"
Expires: 3600
X-MPUSH: i:com.mycompany.myapp:c-10-ap_Kt0:G7SThkASJx2K4Rm1033iR0mIgzI1cLg5xxpST4cjrd_cqQquRLkHMi3eY4g
User-Agent: MyCoolApp
Content-Length: 0

A typical push notification message (to be sent from your server to Apple ASPNS) should look like this:
{
  "headers" :
  {
    "apns-priority" : 10,
    "apns-expiration" : 0,
    "apns-push-type" : "voip",
    "apns-topic": "PACKAGE.voip"
  },
  "aps" :
  {
    "alert" :
    {
      "title" : "Incoming call from 1234",
      "body" : "Incoming VoIP call from 1234"      
    },
    "content-available" : 1,
    "sound" : "default",
    "badge" : 1
  },
  "data" :
  {
    "ntype" : 0,    
    "nfromusername" : "John Smith",
    "nfrom" : "1234",    
    "nmsg" : "Incoming call from 1234",
    "ncallid": "abcdef",
    "ntousr": "9876"    
  }
}


Implementation details:

(This section is useful only if your server doesn't have push support and you wish to implement it)

You can read the details about Apple iOS push notifications staring from here:
    https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server
    https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns/


The "headers" are usually sent as HTTP header fields (not with the payload). Possible headers (-H) are described here:
    https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns/
    https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW1

Possible payload keys:
    https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification    
    https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns/

Troubleshooting APNS HTTP/2 response errors:
    https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/handling_notification_responses_from_apns