【问题标题】:How can I read pushSubscription.endpoint inside service worker?如何在 service worker 中读取 pushSubscription.endpoint?
【发布时间】:2016-02-24 08:47:21
【问题描述】:

我正在使用 Google Chrome Service Worker 为我的网络用户实现推送通知服务。

鉴于 Chrome 当前的安全限制无法发送有效负载,因此我从我的网络服务器获取内容,但是在服务端识别哪个最终用户正在查询推送有效负载非常复杂

是否可以获取 pushSubscription.endpoint 的信息或任何形式或关于我的 service-worker 所连接的唯一标识的信息?

【问题讨论】:

    标签: google-chrome google-cloud-messaging service-worker web-push push-api


    【解决方案1】:

    在 Service Worker 中,您可以使用 self.registration.pushManager.getSubscription()

    self.registration.pushManager.getSubscription().then(function(subscription) {
        if (subscription) {
            // do something with subscription.endpoint
        }
    });
    

    【讨论】:

      猜你喜欢
      • 2017-06-14
      • 1970-01-01
      • 2016-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多