我想仅当我的网站中没有打开的 chrome 选项卡或选项卡已打开且未选择(活动)时才显示 GCM 服务工作线程消息。
\n\n这是我的代码。
\n\n错误: chrome 未定义(\xe2\x80\xa6)。
\n\n清单.json
\n\n { \n "name": "Webplus Express", \n "short_name": "Webplus Express", \n "icons": [{ \n "src": "https://raw.githubusercontent.com/deanhume/typography/gh-pages/icons/typography.png", \n "sizes": "192x192",\n "type": "image/png" \n }], \n "start_url": "/index.html", \n "display": "standalone", \n "gcm_sender_id": "298340340811",\n "gcm_user_visible_only": true,\n "background": {\n "scripts": ["service-worker.js"]\n }, \n "permissions": [\n "gcm","tabs","activeTab"\n ] \n }\nRun Code Online (Sandbox Code Playgroud)\n\nservice-worker.js
\n\n // The service worker running in background to receive the incoming\n// push notifications and user clicks\nself.addEventListener(\'push\', function(event) { …Run Code Online (Sandbox Code Playgroud) service google-chrome worker push-notification google-cloud-messaging