【发布时间】:2017-05-22 17:58:41
【问题描述】:
你好,我是新手,我很难理解 service-worker 中的这个通知,因为我的知识还不够好,所以我可能无法清楚地解释我的问题。
代码如下:
// triggered everytime, when a push notification is received.
self.addEventListener('push', function(event) {
console.info('Event: Push');
var title = 'New commit on Github Repo: RIL';
var body = {
'body': 'Click to see the latest commit',
'tag': 'pwa',
'icon': './images/48x48.png'
};
event.waitUntil(
self.registration.showNotification(title, body)
);
});
这是触发弹出通知的代码,我不明白接受/接收数据的参数在哪里?
我被搜索了很多:https://auth0.com/blog/introduction-to-progressive-web-apps-push-notifications-part-3/, https://developers.google.com/web/updates/2015/03/push-notifications-on-the-open-web 有一些新的数据 JSON 或来自 git-server 或 push api,但我仍然很难理解在哪里接受数据。
抱歉,如果您仍然不明白我的问题是什么。
这里让我想要的简单:
-
1234563 /p>
第二个问题:我能否触发带有 html 中的标题或文本的通知?因为我们可以用 DOM 操作文本?
我是否能够在没有 GCM 或 API 的情况下触发通知,因为我只希望像上面那样在服务工作者中进行简单的通知,而无需传递太多数据。
如果您在没有服务人员但实时的情况下提供更多建议或通知,我当然很乐意阅读它,但我希望我能够理解。
【问题讨论】:
标签: node.js push-notification event-handling progressive-web-apps