<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.markyxfwfwj3j
        {mso-style-name:markyxfwfwj3j;}
span.E-MailFormatvorlage20
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="DE" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">Hi Javier,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">can you list a few app names, this would be great.
</span><span lang="EN-GB" style="font-family:"Segoe UI Emoji",sans-serif;mso-fareast-language:EN-US">😊</span><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">Regarding inclusion of this logic in the default cfg â€“ we usually try to keep the default cfg to cover the basic use cases for VoIP infrastructure. I am not sure if push notifications
 are already there yet, but other people on this list might have another opinion.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">What definitely could be done is to add a dedicated example configuration in the misc/examples directory. If you are interested in contributing something, just create a pull request
 for it.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">Henning<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-left:35.4pt"><b>From:</b> sr-dev <sr-dev-bounces@lists.kamailio.org>
<b>On Behalf Of </b>javier falbo<br>
<b>Sent:</b> Tuesday, June 29, 2021 3:56 PM<br>
<b>To:</b> sr-dev@lists.kamailio.org<br>
<b>Subject:</b> [sr-dev] Implementation of ios/android push notifications module or similar<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:12.0pt;color:black">Hello,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:12.0pt;color:black">As mobile applications based on kamailio are growing exponentially on Play Store and App Store, i would suggest if you could add by default the code for ios/android push
 notifications. <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:12.0pt;color:black">I have problems mainly for incoming call (phone wakeup) on linphone iphone app, as kamailio is missing the push solution. On Android i am using Baresip and works perfect
 without push.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:12.0pt;color:black">Navigating on the web, i found some uncomplete or minimum tutorials to implement this.
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:12.0pt;color:black">Like:
<a href="https://denys-pozniak.medium.com/apple-push-notification-with-kamailio-eeca2f8e08d">
https://denys-pozniak.medium.com/apple-push-notification-with-kamailio-eeca2f8e08d</a><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:12.0pt;color:black">And also some code snippets of a modification of "kamailio.cfg" to add support for ios push notifications. (see below).<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:12.0pt;color:black">Could someone have this already working? Or kamailio official developers could add this by default inside source code?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<blockquote style="border:none #C8C8C8 1.0pt;border-left:solid #C8C8C8 2.25pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:35.4pt">
<span style="font-family:"Courier New";color:#666666"># keep a record of an IPhone for 4 hours<br>
modparam("htable", "htable", "iphone_remote=>size=10;autoexpire=14400;")<br>
modparam("htable", "htable", "iphone_voip=>size=10;autoexpire=14400;")<br>
modparam("htable", "htable", "iphone_check=>size=10;autoexpire=14400;")<br>
modparam("htable", "htable", "vtp=>size=10;autoexpire=120;")</span><span style="color:#666666"><o:p></o:p></span></p>
<p style="margin-left:35.4pt"><span style="color:#666666"><o:p> </o:p></span></p>
<p style="margin-left:35.4pt"><span style="font-family:"Courier New";color:#666666">route[REGISTRAR] {</span><span style="color:#666666"><o:p></o:p></span></p>
<p style="margin-left:35.4pt"><span style="font-family:"Courier New";color:#666666">...</span><span style="color:#666666"><o:p></o:p></span></p>
<p style="margin-left:35.4pt"><span style="font-family:"Courier New";color:#666666">...</span><span style="color:#666666"><o:p></o:p></span></p>
<p style="margin-left:35.4pt"><span style="font-family:"Courier New";color:#666666">        if (save("location")) {<br>
<br>
            # user registered, now look at the useragent header for iPhone string<br>
            if ($hdr(User-Agent)=~"LinphoneiOS.*") {<br>
<br>
<br>
                $var(uri) = @contact.uri;                               # select the uri from contact header<br>
                $var(pn-prid) = $(var(uri){uri.param,pn-prid});         # get the uri param pn-prid from the uri, i.e. 1DF26BC10F597676B<br>
                xlog("!!!! - $var(pn-prid)");<br>
                $var(i) = 0;<br>
                $var(n) = $(var(pn-prid){s.count,&});<br>
<br>
                while( $var(i) <= $var(n)) {<br>
                    $var(pn-prid_item) = $(var(pn-prid){s.select,$var(i),&});<br>
                    $var(pn-prid_type) = $(var(pn-prid_item){s.select,1,:});<br>
                    $var(pn-prid_token) = $(var(pn-prid_item){s.select,0,:});<br>
<br>
                    if ( $var(pn-prid_type) == "remote" ) {<br>
                        $var(pn-prid_remote) = $(var(pn-prid_item){s.select,0,:}) ;<br>
                    }<br>
                    if ( $var(pn-prid_type) == "voip" ) {<br>
                        $var(pn-prid_voip) = $(var(pn-prid_item){s.select,0,:}) ;<br>
                    }<br>
                    $var(i) = $var(i) + 1;<br>
                }<br>
<br>
                xlog("L_INFO","iPhone PUSH tokens for user $fU - remote: $var(pn-prid_remote), voip: $var(pn-prid_voip)");<br>
<br>
                # store the values of tokens to htable with fromUser as key<br>
                $sht(iphone_remote=>$fU) = $var(pn-prid_remote);<br>
                $sht(iphone_voip=>$fU) = $var(pn-prid_voip);<br>
                $sht(iphone_check=>$fU) = 1;<br>
<br>
                if ( $sht(vtp=>id_index::$tU) != $null ) {<br>
                    xlog("L_INFO", "New $rm ru=$ru tu=$tu \n");<br>
                    route(JOIN);<br>
                }<br>
            <br>
            } else {<br>
                # no iphone<br>
                $sht(iphone_check=>$fU) = 0;<br>
            }</span><span style="color:#666666"><o:p></o:p></span></p>
<p style="margin-left:35.4pt"><span style="font-family:"Courier New";color:#666666">...</span><span style="color:#666666"><o:p></o:p></span></p>
<p style="margin-left:35.4pt"><span style="font-family:"Courier New";color:#666666">...</span><span style="color:#666666"><o:p></o:p></span></p>
<p style="margin-left:35.4pt"><span style="font-family:"Courier New";color:#666666">}</span><span style="color:#666666"><o:p></o:p></span></p>
<p style="margin-left:35.4pt"><span style="color:#666666"><o:p> </o:p></span></p>
<p style="margin-left:35.4pt"><span style="color:#666666"><o:p> </o:p></span></p>
<p style="margin-left:35.4pt"><span style="font-family:"Courier New";color:#666666">route[LOCATION] {</span><span style="color:#666666"><o:p></o:p></span></p>
<p style="margin-left:35.4pt"><span style="font-family:"Courier New";color:#666666">...</span><span style="color:#666666"><o:p></o:p></span></p>
<p style="margin-left:35.4pt"><span style="font-family:"Courier New";color:#666666">...</span><span style="color:#666666"><o:p></o:p></span></p>
<p style="margin-left:35.4pt"><span style="font-family:"Courier New";color:#666666">        if (!lookup("location")) {<br>
            $var(rc) = $rc;<br>
                <br>
            # handle PUSH notifications for iPhone<br>
            # iphones should not be registered and contacts stored in database<br>
            # hence lookup should fail and we need to try to push iphone first<br>
            if ($sht(iphone_check=>$tU) == 1) {<br>
                xlog("L_ERR", "[PUSH] The to user has already used iPhone, trying push notifications");<br>
                xlog("L_ERR", "[PUSH] No registration to try, suspending.");<br>
                sl_send_reply("100", "Suspending");<br>
                route(SUSPEND);<br>
                route(RELAY);<br>
                exit;<br>
            }<br>
...</span><span style="color:#666666"><o:p></o:p></span></p>
<p style="margin-left:35.4pt"><span style="font-family:"Courier New";color:#666666">...</span><span style="color:#666666"><o:p></o:p></span></p>
<p style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:35.4pt">
<span style="font-family:"Courier New";color:#666666">        if (is_method("INVITE")) {<br>
            setflag(FLT_ACCMISSED);<br>
            <br>
            # handle PUSH notifications for iPhone<br>
            # in some cases, iphone does not send de-register when going to background<br>
            # for these circumstances, push iphone even if it has an active registration<br>
            if ($sht(iphone_check=>$tU) == 1) {<br>
                xlog("L_ERR", "[PUSH] The to user has already used iPhone, trying push notifications");<br>
                xlog("L_ERR", "[PUSH] No registration to try, suspending.");<br>
                sl_send_reply("100", "Suspending");<br>
                route(SUSPEND);<br>
            }<br>
<br>
        }<br>
        route(RELAY);<br>
        exit;<br>
}</span><span style="color:#666666"><o:p></o:p></span></p>
<p style="margin-left:35.4pt"><span style="color:#666666"><o:p> </o:p></span></p>
<p style="margin-left:35.4pt"><span style="color:#666666"><o:p> </o:p></span></p>
<p style="margin-left:35.4pt"><span style="font-family:"Courier New";color:#666666">route[SUSPEND] {<br>
  if ( !t_suspend() ) {<br>
    xlog("L_ERROR","[SUSPEND]  failed suspending trasaction [$T(id_index):$T(id_label)]\n");<br>
    send_reply("501", "Suspending error");<br>
    exit;<br>
  } else {<br>
    xlog("L_INFO","[SUSPEND]  suspended transaction [$T(id_index):$T(id_label)] $fU=> $rU\n");<br>
    $sht(vtp=>id_index::$rU) = $T(id_index);<br>
    $sht(vtp=>id_label::$rU) = $T(id_label);<br>
    xlog("L_INFO","[SUSPEND] htable key value [$sht(vtp=>id_index::$rU)   --   $sht(vtp=>id_label::$rU)]\n");<br>
    route(SENDPUSH);<br>
    exit;<br>
  }<br>
}<br>
    <br>
route[SENDPUSH] {<br>
    #http_client_query(<a href="http://url/push.php" target="_blank">"http://url/<span class="markyxfwfwj3j">push.php</span>"</a>, "user=$rU\r\npn-tok=$sht(tokens=>$rU)\r\n","Content-Type: text/plain", "$var(result)");<br>
    xlog("!!!!!!!!!!!!!!!!!!!!!! PUSH !!!!!!!!!!!!!!!!!!!");<br>
    xlog("/opt/push/push.sh $ci $sht(iphone_voip=>$tU)");<br>
    exec_avp("/opt/push/push.sh $ci $sht(iphone_voip=>$tU)");<br>
    xlog("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");<br>
    sl_send_reply("100", "Pushing");<br>
}<br>
<br>
route[JOIN] {<br>
    xlog("L_WARN","[JOIN] htable key value [$sht(vtp=>id_index::$tU)   --   $sht(vtp=>id_label::$tU)]\n");<br>
    t_continue("$sht(vtp=>id_index::$tU)", "$sht(vtp=>id_label::$tU)", "RESUME");<br>
    $sht(vtp=>joined::$tU) = 1;<br>
}<br>
    <br>
route[RESUME] {<br>
    lookup("location");<br>
    xlog("L_INFO","[RESUME] rm=$rm ru=$ru du=$du \n");<br>
    t_relay();<br>
    $sht(vtp=>id_index::$tU) = $null;<br>
    $sht(vtp=>id_label::$tU) = $null;<br>
    exit; }</span><span style="color:#666666"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="color:#666666"><o:p> </o:p></span></p>
</div>
</blockquote>
</div>
</body>
</html>