从 Laravel 发送网络推送通知
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48846101/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Sending web push notifications from Laravel
提问by Faustas Butkus
I have a website running Laravelin the back-end, where users can create reports for other users.
我有一个在后端运行Laravel的网站,用户可以在其中为其他用户创建报告。
When the report is created I would like to send a push notification to recipient user's desktop.
创建报告后,我想向收件人用户的桌面发送推送通知。
Do I need to use services like Pusher, OneSignal?
我是否需要使用Pusher、OneSignal 之类的服务?
Any useful site with examples would be appreciated.
任何带有示例的有用站点将不胜感激。
回答by Kenny Horna
Your question
你的问题
You could use Pusher, Redis/Socket.io, Pubnub, etc. Which one to use? well, this is more an opinion-based question.
你可以使用 Pusher、Redis/Socket.io、Pubnub 等。使用哪一个?嗯,这更像是一个基于意见的问题。
This services broadcast events, then in your client apps (like your web front-end) you configure the client-side libraries of the service you choose to subscribe (to channels) and listen to those events.
该服务广播事件,然后在您的客户端应用程序(如您的 Web 前端)中配置您选择订阅(到频道)的服务的客户端库并收听这些事件。
The documentationexplains it better.
文档更好地解释了它。
Examples/tutorials
示例/教程
Pusher
推杆
Thisis a tutorial published by the Pusher team.
这是 Pusher 团队发布的教程。
Redis/Socket.io
Redis/Socket.io
This oneis a Laracast series about this.
这是一个关于此的 Laracast 系列。
Just google.
只是谷歌。
Update
更新
Since a couple of months ago, there's another alternative, a package created exclusively for Laravel:
从几个月前开始,还有另一种选择,一个专为 Laravel 创建的包:
Laravel WebSockets
Laravel 网络套接字
回答by Tuhin Bepari
If you like to show Native Desktop notification then i would suggest Web Push notification. In this way once user subscribed to push notification ,they will get real time notification and does not need to be on your website. https://github.com/laravel-notification-channels/webpush
如果您想显示本机桌面通知,那么我建议使用 Web 推送通知。这样,一旦用户订阅推送通知,他们将收到实时通知,而无需在您的网站上。 https://github.com/laravel-notification-channels/webpush