<p></p>
<p>Hello,</p>
<p>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.</p>
<p>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.</p>
<p>Navigating on the web, i found some uncomplete or minimum tutorials to implement this.<br>
Like: <a href="https://denys-pozniak.medium.com/apple-push-notification-with-kamailio-eeca2f8e08d" rel="nofollow">https://denys-pozniak.medium.com/apple-push-notification-with-kamailio-eeca2f8e08d</a></p>
<p>And also some code snippets of a modification of "kamailio.cfg" to add support for ios push notifications. (see below).<br>
Could someone have this already working? Or kamailio official developers could add this by default inside source code?</p>
<p>`# 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;")</p>
<p>route[REGISTRAR] {</p>
<p>...</p>
<p>...</p>
<pre><code> if (save("location")) {
# user registered, now look at the useragent header for iPhone string
if ($hdr(User-Agent)=~"LinphoneiOS.*") {
$var(uri) = @contact.uri; # select the uri from contact header
$var(pn-prid) = $(var(uri){uri.param,pn-prid}); # get the uri param pn-prid from the uri, i.e. 1DF26BC10F597676B
xlog("!!!! - $var(pn-prid)");
$var(i) = 0;
$var(n) = $(var(pn-prid){s.count,&});
while( $var(i) <= $var(n)) {
$var(pn-prid_item) = $(var(pn-prid){s.select,$var(i),&});
$var(pn-prid_type) = $(var(pn-prid_item){s.select,1,:});
$var(pn-prid_token) = $(var(pn-prid_item){s.select,0,:});
if ( $var(pn-prid_type) == "remote" ) {
$var(pn-prid_remote) = $(var(pn-prid_item){s.select,0,:}) ;
}
if ( $var(pn-prid_type) == "voip" ) {
$var(pn-prid_voip) = $(var(pn-prid_item){s.select,0,:}) ;
}
$var(i) = $var(i) + 1;
}
xlog("L_INFO","iPhone PUSH tokens for user $fU - remote: $var(pn-prid_remote), voip: $var(pn-prid_voip)");
# store the values of tokens to htable with fromUser as key
$sht(iphone_remote=>$fU) = $var(pn-prid_remote);
$sht(iphone_voip=>$fU) = $var(pn-prid_voip);
$sht(iphone_check=>$fU) = 1;
if ( $sht(vtp=>id_index::$tU) != $null ) {
xlog("L_INFO", "New $rm ru=$ru tu=$tu \n");
route(JOIN);
}
} else {
# no iphone
$sht(iphone_check=>$fU) = 0;
}
</code></pre>
<p>...</p>
<p>...</p>
<p>}</p>
<p>route[LOCATION] {</p>
<p>...</p>
<p>...</p>
<pre><code> if (!lookup("location")) {
$var(rc) = $rc;
# handle PUSH notifications for iPhone
# iphones should not be registered and contacts stored in database
# hence lookup should fail and we need to try to push iphone first
if ($sht(iphone_check=>$tU) == 1) {
xlog("L_ERR", "[PUSH] The to user has already used iPhone, trying push notifications");
xlog("L_ERR", "[PUSH] No registration to try, suspending.");
sl_send_reply("100", "Suspending");
route(SUSPEND);
route(RELAY);
exit;
}
</code></pre>
<p>...</p>
<p>...</p>
<pre><code> if (is_method("INVITE")) {
setflag(FLT_ACCMISSED);
# handle PUSH notifications for iPhone
# in some cases, iphone does not send de-register when going to background
# for these circumstances, push iphone even if it has an active registration
if ($sht(iphone_check=>$tU) == 1) {
xlog("L_ERR", "[PUSH] The to user has already used iPhone, trying push notifications");
xlog("L_ERR", "[PUSH] No registration to try, suspending.");
sl_send_reply("100", "Suspending");
route(SUSPEND);
}
}
route(RELAY);
exit;
</code></pre>
<p>}</p>
<p>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>
}</p>
<p>route[SENDPUSH] {<br>
#http_client_query("<a href="http://url/push.php" rel="nofollow">http://url/push.php</a>"<a href="http://url/push.php" rel="nofollow">http://url/push.php</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>
}</p>
<p>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>
}</p>
<p>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; }<br>
`</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/2793">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZO7J3ZCHKI5OLQR6RDTVROZNANCNFSM47URWOYQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/ABO7UZMG2BPD6HNFGJXLHL3TVROZNA5CNFSM47URWOY2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4N5X52KA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/2793",
"url": "https://github.com/kamailio/kamailio/issues/2793",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>