0
我试图将数据从服务器传递给服务人员,但数据对服务人员来说是空的。如何将数据从服务器传递给服务人员
这里是我的代码:
var webpush = require('web-push');
var message = sendData.message;
var subscription_info = sendData.subscription_info;
webpush.setVapidDetails(
'mailto:xxx',
public_key,
private_key
);
webpush.setGCMAPIKey('xxx');
webpush.sendNotification(subscription_info, String(message));
这是执行console.log(消息):
{ text: 'message',
title: 'title',
icon_image: 'http://google.com/xxx.jpg',
link: 'www.google.com' }
这是我的服务人员:
self.addEventListener('push', function(event) {
var title = event.data.title;
var options = {
body: event.data.text,
requireInteraction: true
};
event.waitUntil(self.registration.showNotification(title, options));
});
但标题是不是被认可。我如何将数据从我的服务器传递给服务人员?