简体   繁体   English

将 Linphone 与星号集成以进行推送通知

[英]Integrate Linphone with asterisk for push notification

I have installed the asterisk server and compiled the latest linphone iOS source code.我已经安装了asterisk server并编译了最新的linphone iOS源代码。 Now all works great without being background and lock phone screen, calling.现在一切都很好,没有后台和锁定手机屏幕,打电话。

When app is closed or iPhone screen lock, I can not receive call from other linphone (download from playstore).当应用程序关闭或 iPhone 屏幕锁定时,我无法接听来自其他linphone的电话(从 playstore 下载)。

I have registered both linphone to asterisk server using SIP .我已经使用SIP将两个linphone注册到星号服务器。

I have also created development/distribute certificates, APNS, VOIP push on apple account.我还在苹果帐户上创建了development/distribute certificates, APNS, VOIP推送。

But still i can not receive call to iOS app, So my question:但我仍然无法接到 iOS 应用程序的电话,所以我的问题是:

  1. Will i have to use Any push supported proxy for that like flexisip, Opensips, kamailio etc. or I can just use Asterisk and Linphone or any other way to get notification when app is closed or lock screen?我是否必须为flexisip, Opensips, kamailio等使用任何支持推送的代理,或者我可以只使用AsteriskLinphone或任何其他方式在应用程序关闭或锁定屏幕时获得通知?

Also will have to use any third party server for push notification to wakeup the app, like pusher, onesignal ?还必须使用任何第三方服务器来推送通知以wakeup the app, like pusher, onesignal

Thanks谢谢

You can use flexisip.你可以使用 flexisip。 It semi-working and no documentation它是半工作的,没有文档

You can use asterisk or kamailio, but you should do push yourself by external scripts and dialplan.你可以使用 asterisk 或 kamailio,但你应该通过外部脚本和拨号规则来推动自己。

I'm thinkering with linphone and flexisip as well and it's not working for me.我也在考虑 linphone 和 flexisip,但它对我不起作用。 I thought I could ditch flexisip and push directly from asterisk before dialing the extension.我想我可以放弃 flexisip 并在拨打分机号之前直接从 asterisk 推送。 I've got a agi script that gets the pn-tok from the contact and then does a push:我有一个 agi 脚本,它从联系人那里获取 pn-tok,然后进行推送:

$serverKey = "   long string coming from firebase   ";
$notif = ['title' => 'You have a call', 'body' => "Call from $CLI"];
$headers = [CURLOPT_HTTPHEADER => ["Authorization: key=$serverKey", 'Content-Type: application/json']];
$pjsipContact = ast_get_var("PJSIP_AOR(1000,contact)");
if(!empty($pjsipContact)) {
  $pjsipUri = ast_get_var("PJSIP_CONTACT($pjsipContact,uri)");
  preg_match('/pn-tok=([^;]+)/', $pjsipUri, $toArr);
  if (count($toArr) == 2) {
    log_cli("send noti to {$toArr[1]}");
    curlGetPage('https://fcm.googleapis.com/fcm/send', json_encode(['to' => $toArr[1], 'notification' => $notif]), $headers, 443, 'POST', TRUE);
  }
}

with this agi the phone receive the push and shows it in the notifications, but linphone doesn't come back to life.使用此 agi,手机会收到推送并在通知中显示,但 linphone 不会恢复生机。 Is there a specific format for the push notification to actually wake up linphone and make it register again?推送通知是否有特定格式来实际唤醒 linphone 并使其再次注册?

Thanks.谢谢。

You can certainly push to your own compiled Linphone app to wake it before a call using asterisk only.您当然可以推送到您自己编译的 Linphone 应用程序以在仅使用星号的呼叫之前唤醒它。 The gist is to get the push token from the client contact info using the DB dialplan function and passing it out to an AGI script which will then use the token to initiate the push and wake the device.要点是使用 DB 拨号计划功能从客户端联系信息中获取推送令牌,并将其传递给 AGI 脚本,然后该脚本将使用令牌启动推送并唤醒设备。 You need to add a wait delay to allow the phone to re-register first, then you can do a dial() to the extension.您需要添加等待延迟以允许电话先重新注册,然后您可以对分机执行 dial() 。 With Android you need to use the "data" msg type and not the "notification" type or the phone won't wake and only display a notification.对于 Android,您需要使用“数据”消息类型而不是“通知”类型,否则手机不会唤醒,只会显示通知。 Please see this post for details on how to accomplish this.有关如何完成此操作的详细信息,请参阅这篇文章。 Note, the post discusses Android but can be easily adapted to IOS by modifying the push.php script.请注意,该帖子讨论的是 Android,但可以通过修改 push.php 脚本轻松适应 IOS。

https://community.asterisk.org/t/interest-in-implementing-sip-push-notification/75563/19 https://community.asterisk.org/t/interest-in-implementing-sip-push-notification/75563/19

在此处输入图像描述 For voip calls mobile client has to receive push notification and then register itself with the SIP server in order to receive Call-invite.对于 voip 呼叫,移动客户端必须接收推送通知,然后向 SIP 服务器注册自己才能接收呼叫邀请。 So any softswitch or PBX can have this mechanism to initiate push-notification and wait for the offline client to come online and send invite request.所以任何软交换或PBX都可以有这种机制来发起推送通知并等待离线客户端上线并发送邀请请求。 So PBX plays important role here to wait and forward invite after client appears online.所以 PBX 在这里起着重要的作用,等待客户端出现在线后转发邀请。

You can use push scripts from this github repository .您可以使用此github 存储库中的推送脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM