优势17-PushManager.Subscribe失败,出现AbortError

Nun*_*uno 5 push-notification service-worker microsoft-edge pwa

Edge 17支持服务人员,当然也支持PushManager。

但是,即使我的“推送通知”实现在支持它们的所有浏览器中都可以使用,但它似乎不适用于Edge。

if ('PushManager' in window) {
    registration.pushManager.subscribe({
        userVisibleOnly: true,
        applicationServerKey: urlBase64ToUint8Array('xxxxxxx')
    })
    .then(function(subscription) {
        console.log('All good');
    })
    .catch(function(err) {
        console.error(err);
    });
}
Run Code Online (Sandbox Code Playgroud)

这在“捕获”中失败:

[对象DOMException]:{代码:20,消息:“ AbortError”,名称:“ AbortError”}

这是Edge的已知问题吗?我做错什么了吗?

JOT*_*OTN 0

我收到此错误,因此我查看了这段有效的代码:

https://webpushdemo.azurewebsites.net/

为我解决的是这部分:

navigator.serviceWorker.ready.then(/* registration function here*/
Run Code Online (Sandbox Code Playgroud)