• <small id='NWti7'></small><noframes id='NWti7'>

      <bdo id='NWti7'></bdo><ul id='NWti7'></ul>
    1. <i id='NWti7'><tr id='NWti7'><dt id='NWti7'><q id='NWti7'><span id='NWti7'><b id='NWti7'><form id='NWti7'><ins id='NWti7'></ins><ul id='NWti7'></ul><sub id='NWti7'></sub></form><legend id='NWti7'></legend><bdo id='NWti7'><pre id='NWti7'><center id='NWti7'></center></pre></bdo></b><th id='NWti7'></th></span></q></dt></tr></i><div id='NWti7'><tfoot id='NWti7'></tfoot><dl id='NWti7'><fieldset id='NWti7'></fieldset></dl></div>
    2. <legend id='NWti7'><style id='NWti7'><dir id='NWti7'><q id='NWti7'></q></dir></style></legend>

      1. <tfoot id='NWti7'></tfoot>
      2. 如何从 javascript 注册到 GCM 主题(适用于 Chrome)

        How to get registered into GCM topics from javascript (for Chrome)(如何从 javascript 注册到 GCM 主题(适用于 Chrome))

      3. <i id='9i46W'><tr id='9i46W'><dt id='9i46W'><q id='9i46W'><span id='9i46W'><b id='9i46W'><form id='9i46W'><ins id='9i46W'></ins><ul id='9i46W'></ul><sub id='9i46W'></sub></form><legend id='9i46W'></legend><bdo id='9i46W'><pre id='9i46W'><center id='9i46W'></center></pre></bdo></b><th id='9i46W'></th></span></q></dt></tr></i><div id='9i46W'><tfoot id='9i46W'></tfoot><dl id='9i46W'><fieldset id='9i46W'></fieldset></dl></div>
        <tfoot id='9i46W'></tfoot>

      4. <legend id='9i46W'><style id='9i46W'><dir id='9i46W'><q id='9i46W'></q></dir></style></legend>

          • <small id='9i46W'></small><noframes id='9i46W'>

                <bdo id='9i46W'></bdo><ul id='9i46W'></ul>
                    <tbody id='9i46W'></tbody>

                  本文介绍了如何从 javascript 注册到 GCM 主题(适用于 Chrome)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这里是关于如何实现的很好的文档Chrome 中的 Google 云消息传递 (GCM).但我在这里或任何地方都没有找到任何参考如何使用 javascript(用于 Chrome)订阅主题.

                  Here is a nice documentation on how to implement Google Cloud Messaging (GCM) in Chrome. But I do not found any reference here or anywhere how to subscribe to a topic using javascript (for Chrome).

                  在这里,我找到了如何为 Android 执行任务的参考:https://developers.google.com/cloud-messaging/topic-messaging#subscribe-to-a-topic

                  Here I have found a reference how to do the task for Android: https://developers.google.com/cloud-messaging/topic-messaging#subscribe-to-a-topic

                  在 GCM 中订阅主题的 Java 代码(Android):

                  Java code(Android) for subscribe to a topic in GCM:

                  private void subscribeTopics(String token) throws IOException {
                      GcmPubSub pubSub = GcmPubSub.getInstance(this);
                      for (String topic : TOPICS) {
                          pubSub.subscribe(token, "/topics/" + topic, null);
                      }
                  }
                  

                  我不想要的东西

                  我不是在寻找 Chrome 应用程序/扩展程序的方法.

                  I am NOT looking ways for Chrome app/Extension.

                  我想要什么

                  我想向我的所有用户发送推送通知.到目前为止,我知道这可以通过两种方式实现:

                  I want to send push notification to all my users. So far I know this can be achievable in two ways:

                  1. 向主题推送消息
                  2. 或者我必须:您需要发送设备的 reg id 列表,并且此列表不应超过 1000,这是 GCM 的限制,如果您想向超过 1000 个设备发送消息,那么您需要中断以 1000 个为单位的列表."

                  我想避开第 2 点.

                  我的问题

                  所以,我的问题是有没有办法使用 Javascript for Chrome 浏览器(用于网页)订阅 GCM 的主题?如果有,那该怎么做呢?

                  So, My question is is there any way to subscribe to a topic for GCM using Javascript for Chrome browser (for web pages)? If there, then how to do that?

                  推荐答案

                  Web 推送不支持 GCM 主题.原因很可能与即将添加的 payloads 需要为每个用户使用不同的密钥进行加密.

                  GCM topics are not supported by web push. The reason is likely to be related to the upcoming addition of payloads which are required to be encrypted with a different key per user.

                  所以我担心你会被 2) 困住.这当然取决于您拥有多少用户,但请记住,如果您要使用主题,您可能会立即向数百万人发送消息.收到消息后,所有这些用户都会https-ing"返回您的站点以获取显示通知所需的信息,因此如果该主题要被很多人使用,您将冒着 DOSing 自己的风险.以 1000 个为一组进行批处理有助于限制传入流量.

                  So I'm afraid you are stuck with 2). This of course depends on how many users you have but keep in mind that with the current state of affairs you could be instantly sending a message to millions of people if you were to be using topics. Upon receiving the message all those users would be "https-ing" back to your site to fetch the information needed to display the notification so you run the risk of DOSing yourself if the topic were to be used by lot's of people. Batching in groups of 1000 helps throttling the incoming traffic.

                  这篇关于如何从 javascript 注册到 GCM 主题(适用于 Chrome)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  quot;Status Code:200 OK (from ServiceWorker)quot; in Chrome Network DevTools?(“状态码:200 OK(来自 ServiceWorker)在 Chrome 网络开发工具中?)
                  How to set a header for a HTTP GET request, and trigger file download?(如何为 HTTP GET 请求设置标头并触发文件下载?)
                  Adding custom HTTP headers using JavaScript(使用 JavaScript 添加自定义 HTTP 标头)
                  SQL Query DocumentDB in Azure Functions by an integer not working(通过整数在 Azure Functions 中 SQL 查询 DocumentDB 不起作用)
                  Azure Functions [JavaScript / Node.js] - HTTP call, good practices(Azure Functions [JavaScript/Node.js] - HTTP 调用,良好实践)
                  Azure Functions - Import Custom Node Module(Azure Functions - 导入自定义节点模块)
                  • <bdo id='trThw'></bdo><ul id='trThw'></ul>
                      <legend id='trThw'><style id='trThw'><dir id='trThw'><q id='trThw'></q></dir></style></legend>

                          <tbody id='trThw'></tbody>

                          <i id='trThw'><tr id='trThw'><dt id='trThw'><q id='trThw'><span id='trThw'><b id='trThw'><form id='trThw'><ins id='trThw'></ins><ul id='trThw'></ul><sub id='trThw'></sub></form><legend id='trThw'></legend><bdo id='trThw'><pre id='trThw'><center id='trThw'></center></pre></bdo></b><th id='trThw'></th></span></q></dt></tr></i><div id='trThw'><tfoot id='trThw'></tfoot><dl id='trThw'><fieldset id='trThw'></fieldset></dl></div>

                            <small id='trThw'></small><noframes id='trThw'>

                          • <tfoot id='trThw'></tfoot>