chrome扩展,服务人员接收推送通知 [英] chrome extension with service worker receiving push notifications

查看:163
本文介绍了chrome扩展,服务人员接收推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功建立了一个服务人员,可以在此之后接收推送通知教程.

I've successfully built a service worker that receives push notifications following this tutorial.

我正在尝试构建一个Chrome扩展程序,该扩展程序将允许我订阅推送通知.但是似乎扩展程序运行时不支持服务工作者.

And I was trying to build a chrome extension that would allow me to subcripe to the push notifications. But it seems that when the extension runs the service worker is not supported.

Service Worker Error :^( DOMException: Failed to register a ServiceWorker: The URL protocol of the current origin ('chrome-extension://dghajjpcbhcpnnkkgehjhhceemhcacoc') is not supported.

我是否对manifest.js缺少某些权限?

Am I missing some permissions on the manifest.js?

对于Chrome扩展程序,我遵循了本教程.

I followed this tutorial for the Chrome extension.

推荐答案

为Chrome扩展启用Service Workers仍在进行中.您可以在此处进行跟踪.看来它已经在Canary和Dev频道中提供了.

Enabling Service Workers for Chrome extensions is still a work in progress. You can track it here. It seems that it is already available in the Canary and Dev channels.

您不需要服务人员即可在Chrome扩展程序中接收推送通知.您可以使用 chrome.gcm API .

You don't need a Service Worker to be able to receive push notifications in a Chrome extension. You can use the chrome.gcm API.

这篇关于chrome扩展,服务人员接收推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆