Giter Club home page Giter Club logo

pwa-doc's Issues

反馈:engage-retain-users/how-push-works.md

//使用 webpush.sendNotification 发起通知,报下面错误:
{ Error: read ECONNRESET
at exports._errnoException (util.js:1022:11)
at TLSWrap.onread (net.js:569:26) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }

开了翻墙,服务器为express,代码如下,为本地开发localhost访问环境,没有https,请问有办法处理吗?

//之前保存的pushSubscription
let pushSubscription = JSON.parse(fs.readFileSync('pushSubscription.txt'));

var body = '谢谢关注';
var iconUrl = 'http://localhost:8087/images/huiju.png';

webpush.sendNotification(pushSubscription,
JSON.stringify({
msg: body,
url: 'http://localhost:8087',
icon: iconUrl,
type: 'register'
}))
.then(result => {
console.log(result);
res.send({status:0,mes:"发送成功"});
})
.catch(err => {
console.log(err);
});

反馈:engage-retain-users/how-push-works.md

function subscribe(serviceWorkerReg) {
serviceWorkerReg.pushManager.subscribe({ // 2. 订阅
userVisibleOnly: true,
applicationServerKey: urlBase64ToUint8Array('')
})
.then(function (subscription) {
// 3. 发送推送订阅对象到服务器,具体实现中发送请求到后端api
sendEndpointInSubscription(subscription);
})
.catch(function () {
if (Notification.permission === 'denied') {
// 用户拒绝了订阅请求
}
});
}

这段代码,为什么我怎么操作不都能执行到【 // 3. 发送推送订阅对象到服务器】这一步,求解,谢谢!

反馈:offline-and-cache-loading/service-worker/how-to-use-service-worker.md

install

上面写的是Service Worker 安装成功后,install 事件被触发,但是接着下面ExtendableEvent.waitUntil() 方法——这会确保 Service Worker 不会在 waitUntil() 里面的代码执行完毕之前安装完成

觉得这里有点矛盾啊,按理说是通过install注册回调函数,当install成功,也就是servece worker注册成功之后,才会执行回调,但是这里为什么写的是ExtendableEvent.waitUntil() 方法——这会确保 Service Worker 不会在 waitUntil() 里面的代码执行完毕之前安装完成呢?有些不解。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.