火狐推送API - AbortError:获取推送订阅时出错。

7

我正在使用Firefox Nightly 46.0a1版本(OS X只有42v,而Push API需要43v)。

但我遇到了以下错误:

DOMException [AbortError: "Error retrieving push subscription"
code: 20
nsresult: 0x80530014]

这里是一个代码片段,其中出现了这个错误:
navigator.serviceWorker.ready.then(function (serviceWorkerRegistration) {

    serviceWorkerRegistration.pushManager.subscribe()
        .then(function (subscription) {
            endpoint = subscription.endpoint;
            console.log('subscription endpoint: ', subscription.endpoint);
            subscribeOnServer();
        })
        .catch(function (e) {

            // here that error is raised

            errorNotification.innerHTML = 'Unable to subscribe to push';
        }
    });
});

在Chrome中,此处不会抛出任何内容,我可以使用正确的终端点进行订阅。

1
我遇到了类似的错误。在about:config中启用所有标志dom.push.*有所帮助。 - Martin Ždila
dom.push.adaptive.enabled 对我起作用了。 - Ilya Kochetov
我也遇到了这个问题,但由于Firefox上默认的serviceworker和push未启用,所以我更新了about:config,然后出现了以下错误信息:AbortError: Error retrieving push subscription在重启Firefox后,问题得到了解决。我认为新的配置在重启前不会生效。 我知道这是一个旧问题,而且肯定是Firefox的不同版本,但也许情况是相同的。 - Alsemany
3个回答

3

最近发现,如果您的浏览器在不支持Web Socket的代理后面(推送服务在内部使用Web Socket),可能会出现此错误。


1

我这里没有出现错误。

你的代码片段中有语法错误,但我猜那不是问题所在(否则在Chrome中也会失败)。

这是我使用的代码片段:

navigator.serviceWorker.ready
.then(function(serviceWorkerRegistration) {
  console.log('asd');
  serviceWorkerRegistration.pushManager.subscribe()
  .then(function(subscription) {
    endpoint = subscription.endpoint;
    console.log('subscription endpoint: ', subscription.endpoint);
  })
  .catch(function(e) {
    console.log(e);
  });
});

0

当我的服务工作者出现错误(尝试访问不存在的indexedDb存储)时,我遇到了这个错误,因此即使它已安装,但推送通知也无法订阅,出现了上述错误。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接