Html 移动网络应用的推送通知功能
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9156099/
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
Push notification facility for mobile web app
提问by Volatil3
I have a simple scenario, to receive notification on mobile devices whenever it's generated from Server.
我有一个简单的场景,当它从服务器生成时接收移动设备上的通知。
I know this facility is available in native iOS app and Android but I am trying to avoid native path. What I would like that:
我知道这个工具在原生 iOS 应用程序和 Android 中可用,但我试图避免原生路径。我想要的是:
- A mobile web app which can be access by visiting a URL
- User have ability to create a bookmark on Home screen so that it gets feeling of native app Icon.
- Getting badges of notification(no of messages in round shape)
- Able to receive notification even if browser is closed.
- 可以通过访问 URL 访问的移动网络应用程序
- 用户可以在主屏幕上创建书签,以便获得本机应用程序图标的感觉。
- 获取通知徽章(没有圆形消息)
- 即使浏览器关闭也能收到通知。
I know there is a possibility of server side events/Web Sockets but can a web app emulate push notification features?
我知道有可能发生服务器端事件/网络套接字,但是网络应用程序可以模拟推送通知功能吗?
回答by owencm
You can do this without a hybrid app, native app, or requiring users to install Pushover. It is possible to build a "progressive web app" that can send push notifications even after the page has been closed.
您可以在没有混合应用程序、本机应用程序或要求用户安装 Pushover 的情况下执行此操作。可以构建一个“渐进式网络应用程序”,即使在页面关闭后也可以发送推送通知。
These work today in Chrome for Android (and other browsers seem to be implementing support), but there is no support on iOS.
这些在今天适用于 Android 的 Chrome(和其他浏览器似乎正在实现支持)中工作,但在 iOS 上不支持。
Check out this demo, and this guide explains how to do it: https://developers.google.com/web/fundamentals/engage-and-retain/push-notifications/
查看此演示,本指南解释了如何操作:https: //developers.google.com/web/fundamentals/engage-and-retain/push-notifications/
回答by Kai Carver
回答by collimarco
Able to receive notification even if browser is closed.
即使浏览器关闭也能收到通知。
You cannot use WebSockets for this. You must use the more recent Push API. Currently it is supported by all major browsers, except Safari on iOS.
您不能为此使用 WebSocket。您必须使用更新的Push API。目前,除 iOS 上的 Safari 外,所有主要浏览器都支持它。
However adding support for the Push API from scratch is a lot of work: I suggest to use a third party service like Pushpad(I am the founder).
然而,从头开始添加对 Push API 的支持需要做很多工作:我建议使用像Pushpad这样的第三方服务(我是创始人)。
回答by Luffy
I am using this architecture
我正在使用这种架构
sockjs + rabbitmq + stomp
sockjs + rabbitmq + stomp
References:
参考:
回答by Tekinnn
You can use a Plug-in for mobile Push Notification to PhoneGap (mobile web application)
您可以使用 Plug-in for Mobile Push Notification to PhoneGap(移动 Web 应用程序)
https://github.com/awysocki/C2DM-PhoneGap
https://github.com/awysocki/C2DM-PhoneGap
Push notification or server push is the latest way to send data from the server to the client. Have you noticed how Gmail receives and displays the new email that arrives in your inbox? You don't need to refresh the browser or click some refresh button to send request and receive latest data from the server.
推送通知或服务器推送是从服务器向客户端发送数据的最新方式。您是否注意到 Gmail 如何接收和显示到达收件箱的新电子邮件?您不需要刷新浏览器或单击某些刷新按钮来发送请求并从服务器接收最新数据。
回答by Simply Innovative
According to my understanding you can build a hybrid app which will allow you to access both native and web functionality. To achieve this you can consider using Phonegap. This will allow you to use Push Notification service too.
根据我的理解,您可以构建一个混合应用程序,它允许您访问本机和 Web 功能。为此,您可以考虑使用 Phonegap。这也将允许您使用推送通知服务。
You can consider Test Flight a 3rd party software for your app distribution on Android and iOS platform. Test Flight is free and recently acquired Apple.
您可以将 Test Flight 视为在 Android 和 iOS 平台上分发应用程序的第 3 方软件。Test Flight 是免费的,最近收购了 Apple。