- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试使用 AJAX 来检索我想在用户端显示的推送通知的详细信息,但它还不起作用。
/*
*
* Push Notifications codelab
* Copyright 2015 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*
*/
// Version 0.1
//'use strict';
console.log('Started', self);
self.addEventListener('install', function(event) {
self.skipWaiting();
console.log('Installed', event);
});
self.addEventListener('activate', function(event) {
console.log('Activated', event);
});
self.addEventListener('push', function(event) {
console.log('Push message', event);
var title = 'Push message';
var xhttp = new XMLHttpRequest();
xhttp.open("GET", "https://www.domain.nl/devtest/1.php", false);
xhttp.send();
title = xhttp.responseText;
event.waitUntil(
self.registration.showNotification(data, {
'body': 'The Message',
'icon': 'images/icon.png'
})
);
});
当我使用 GCM 向客户端发送推送通知时,Chrome 在服务 worker 上给出了这个错误:
sw.js:39 Uncaught ReferenceError: XMLHttpRequest is not defined
最佳答案
XMLHttpRequest
已被弃用,它在 Service Worker 范围内不可用。您可以使用 Fetch API
而不是 XMLHttpRequest
.
关于javascript - Service Worker 和 AJAX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38393126/
如果一个域有多个团队和多个 Web 应用程序,那么注册 Service Worker 来管理整个站点的最佳建议是什么?具有范围的顶级服务 worker /或子域中的多个服务 worker ?由于一个域
我开发了一个应用程序来分析播放 YouTube 视频时的网络流量。它使用 chrome.webRequest,我使用 onHeadersReceived 事件计算流量。 我想使用 service wo
假设我提供了不同网站使用的推送通知服务。此服务需要在我的客户站点上安装服务 worker 。我希望架构具有一些属性: 完全静态资源。安装service worker文件和配置JS片段等过程只需要完成一
我要缓存某人网站中的特定请求 ,那么我发现 service worker 是一个不错的选择。但我找不到任何方法 通过 tampermonkey 注入(inject)一个 service worker
当 Service Worker 更新时,它不会以正确的方式控制页面;它进入“等待”状态,等待被激活。 令人惊讶的是,更新后的 Service Worker 甚至在刷新页面后都无法控制选项卡。谷歌解释
有谁知道是否有办法在 service worker 中获取此号码或日期: 将我的服务 worker 缓存命名为 cache-1182 会很方便或 cache-20171127171448 我想在安装事
这link说: Workers may spawn more workers if they wish. So-called sub-workers must be hosted within the
有许多关于使用 ngsw-worker.js 安装 ServiceWorker 的分步指南;然而,甚至没有关于使用 safety-worker.js 卸载 ServiceWorker 的分步指南。 s
我正在尝试为我的网站使用后台定期同步。我正在使用 localhost 并在 1*1000 毫秒时注册 periodicsync 事件,但这根本不会触发。 我看过这个demo ,但即使我将该网站安装为应
我试图让用户安排一个周期性任务。我还在一个容器中运行多个 celery worker 。我对该容器的命令过去是这样的: celery worker -c 4 -B -l INFO -A my.cele
从我所看到的,你甚至可以缓存一个网页。根据此文档:https://www.mnot.net/cache_docs/#BROWSER ,表示可以缓存在浏览器缓存中。我看到即使是 serviceworke
我只是在测试 Service Worker 的功能以了解其工作原理。所以现在我遇到了一个问题。 var CACHE_NAME = 'my-site-cache-v1'; var urlsToCache
下图显示安装了两名工作人员 - 一名处于事件状态,另一名未处于事件状态(刚刚安装)。 注册 service worker 更改 service-worker.js并重新加载页面。 逻辑是 Servic
我正在尝试学习渐进式 Web 应用程序的一些基础知识,并且在我阅读的其中一篇教程中学习 [在安装了 service worker 并且用户导航到不同的页面或刷新后,service worker 将开始
我正在开发一个应用程序,其目标是定期(例如每小时)向用户发送通知。 我的想法是使用一个可以在选项卡关闭后运行的服务 worker ,并继续向用户发送这些通知。 网页需要能够与 Service Work
我正在尝试为一个简单但旧的 Django Web 应用程序安装 ServiceWorker。我开始使用示例 read-through caching example from the Chrome t
在我们开发的情况下,我们提供来自 https://localhost 的文件因为该应用程序托管在 salesforce.com 中。在 chrome service worker 中,chrome 会
我是服务人员的新手,并且浏览了各种文档(Google,Mozilla,serviceworke.rs,Github,StackOverflow questions)。最有用的是ServiceWorke
我正在解决一个问题,我有一组“热情的 worker ”。这意味着它们被维护在内存中,维护自己的上下文并且是可调用的。我一直在研究各种 Go Worker 实现,但都依赖于闭包或返回结果的简单计算函数。
我有一个部署到静态服务器的非根路径的网络应用程序。即MyApp构建时部署到路径/文件夹 https://example.com/myapp . MyApp正在使用 vue 和 webpack 所以我添
我是一名优秀的程序员,十分优秀!