HTML5 推送通知 - 其他推送方式的示例
HTML5 Push Notifications - examples of other ways to push
在 Google IO 2015 上,HTML5 和服务人员就 Chrome 的推送通知进行了很多讨论。
现在还处于早期阶段,地上的例子还很少。我正在寻找如何从 Google 云消息传递以外的平台实现推送的服务器端示例 - 例如,Azure 移动服务或 AWS。
本教程(https://azure.microsoft.com/en-us/documentation/articles/mobile-services-javascript-backend-android-get-started-push/ ) does use GCM, but the general technique is supported across all platforms, iOS and Windows so you are not tied to GCM (for example this tutorial: https://azure.microsoft.com/en-us/documentation/articles/mobile-services-javascript-backend-windows-universal-dotnet-get-started-push/)
目前 Chrome 上的推送与 GCM 绑定,有一个 new standard being actively worked on 将使推送服务都使用相同的 API。当这种情况发生时,我希望 Chrome 和 GCM 将实施它,然后您将能够实施单个 API。 Firefox 已经在夜间构建中使用了该标准的早期版本。现在请记住,Chrome 和 Firefox 之间的情况可能会有所不同。
关于服务器端示例 - 我没有任何 Azure 代码,但是如果你查看这个 simple-push-demo 有一个基本上与 GCM 交互的 curl 命令 restful API 发起推送消息。
示例:
curl --header "Authorization: key=<YOUR_PUBLIC_API_KEY>"
--header "Content-Type: application/json"
https://android.googleapis.com/gcm/send
-d "{\"registration_ids\":[\"<YOUR_REGISTRATION_ID>\"]}"
您可以使用它来了解 API 的工作原理并以您需要的任何服务器端语言实现它(它基本上是一个带有特殊 header 的 post 请求).
您可以查看 source code for the simple push demo on Github.
演示中用于从服务器发送推送消息的后端代码(为 AppEngine 编写在 Python 中)is on Github here.
最后,如果你想要一个完整的教程,那么 check out this article on html5rocks。
在 Google IO 2015 上,HTML5 和服务人员就 Chrome 的推送通知进行了很多讨论。
现在还处于早期阶段,地上的例子还很少。我正在寻找如何从 Google 云消息传递以外的平台实现推送的服务器端示例 - 例如,Azure 移动服务或 AWS。
本教程(https://azure.microsoft.com/en-us/documentation/articles/mobile-services-javascript-backend-android-get-started-push/ ) does use GCM, but the general technique is supported across all platforms, iOS and Windows so you are not tied to GCM (for example this tutorial: https://azure.microsoft.com/en-us/documentation/articles/mobile-services-javascript-backend-windows-universal-dotnet-get-started-push/)
目前 Chrome 上的推送与 GCM 绑定,有一个 new standard being actively worked on 将使推送服务都使用相同的 API。当这种情况发生时,我希望 Chrome 和 GCM 将实施它,然后您将能够实施单个 API。 Firefox 已经在夜间构建中使用了该标准的早期版本。现在请记住,Chrome 和 Firefox 之间的情况可能会有所不同。
关于服务器端示例 - 我没有任何 Azure 代码,但是如果你查看这个 simple-push-demo 有一个基本上与 GCM 交互的 curl 命令 restful API 发起推送消息。
示例:
curl --header "Authorization: key=<YOUR_PUBLIC_API_KEY>"
--header "Content-Type: application/json"
https://android.googleapis.com/gcm/send
-d "{\"registration_ids\":[\"<YOUR_REGISTRATION_ID>\"]}"
您可以使用它来了解 API 的工作原理并以您需要的任何服务器端语言实现它(它基本上是一个带有特殊 header 的 post 请求).
您可以查看 source code for the simple push demo on Github.
演示中用于从服务器发送推送消息的后端代码(为 AppEngine 编写在 Python 中)is on Github here.
最后,如果你想要一个完整的教程,那么 check out this article on html5rocks。