Volodymyr Tarasenko Copyright © 2014 Volodymyr Tarasenko
Admin Guide
- Overview 1. License
- Dependencies 1. Kamailio Modules 2. External Libraries or Applications
- Parameters 1. push_db (string) 2. push_table (string) 3. push_flag (integer) 4. push_apns_cert (string) 5. push_apns_key (string) 6. push_apns_cafile (string) 7. push_apns_server (string) 8. push_apns_port (integer) 9. push_apns_alert (string) 10. push_apns_sound (string) 11. push_apns_badge (integer) 12. push_apns_rtimeout (integer) 13. push_apns_feedback_server (string) 14. push_apns_feedback_port (integer) 15. push_apns_feedback_rtimeout (integer)
- Functions 1. push_request 2. push_register 3. push_message
This is a module which provides Push notification service for Kamailio. It implements the APNS interface (currently). In nearest plans extend it to support Android push notifications (GCM)
This module release under GNU GPLv3 license. The license could be found in this repository or downloaded from GNU http://www.gnu.org/licenses/gpl.txt
- Kamailio Modules
- External Libraries or Applications
- No dependencies on other Kamailio modules.
The following libraries or applications must be installed before running Kamailio with this module loaded:
- openssl
Defines database to store push related information
modparam("push", "push_db", DBURL)
Defines table to store push related information
modparam("push", "push_table", "push_apns")
Set the flag for the push, next values are possible:
- 0 - establish connection to push server immediately after start
- 1 - establish connection upon request
- 2 - do not reconnect in case of error
modparam("push", "push_flag", 0)
Defines the path to apns cert file
modparam("push", "push_apns_cert", "/etc/kamailio/apns/cert.pem")
Defines the path to apns key file
modparam("push", "push_apns_key", "/etc/kamailio/apns/key.pem")
Defines the path to apns CA cert if any, it should be defined if test server is used
modparam("push", "push_apns_cafile", "/etc/kamailio/apns/entrust_2048_ca.pem")
Defines apns server to use
modparam("push", "push_apns_server", "gateway.sandbox.push.apple.com")
Defines apns server port
modparam("push", "push_apns_port", 2195)
Defines default apns alert string
Defines default apns sound file to play on device
Defines default apns badge number
Defines read timeout for apns communication, defined in microseconds
modparam("push", "push_apns_rtimeout", 10000)
Defines apns feedback server to use, if any
Defines apns feedback server port
Defines read timeout for apns feedback comunnication, defined in microseconds
The function to send APNS push notification
device_token: 32 chars device token message: message to be sent to device in push notification custom: sustom json payload to be added to APNS push notification
push_request("1abcdef01234567890abcdef12345678", "message available");
Register device and assign its device token to contact
device_token: device token to be registered
reg_fetch_contacts("location", "$fu", "callee")
xlog("Contact: $ct, instance $(ct{param.value, +sip.instance})");
push_register($(ct{param.value, pn-tok}));
Sends push message to registered device
msg: message to be sent custom: sustom json payload to be added to APNS push notification
request_route {
if (is_method("INVITE"))
{
setflag(FLT_ACC); # do accounting
if (!registered("location"))
{
sl_reply_error();
exit;
}
if (!has_totag())
{
xlog("Sending push message...");
push_message("Incoming call", "\"notificationCommand\":\"NotificationCommandCall\", \"callState\":\"Started\"");
}
}
}
failure_route[MANAGE_FAILURE] {
route(NATMANAGE);
if (t_is_canceled()) {
push_message("Missed call", "\"notificationCommand\":\"NotificationCommandCall\", \"callState\":\"Missed\"");
exit;
}
In this example push message will be sent to device with custom additional json payload:
{
"notificationCommand":"NotificationCommandCall",
"callState":"Started"
}
{ "notificationCommand": "NotificationCommandCall",
"callState":"Missed"
}