我正在使用 firebase 通知,并添加自定义按钮。但是推送通知只显示文本而不是操作按钮......像这样:
这是代码片段:
self.addEventListener('push', function (event) {
console.log('Push Notification Received.');
var eventData = event.data.text();
obj = JSON.parse(eventData); //Parse the received JSON object.
notifyPayload = obj;
var options = {
body: obj.data.body,
icon: obj.data.icon,
actions: [
{
action: 'coffee-action',
title: 'Coffee',
icon: ''
},
{
action: 'doughnut-action',
title: 'Doughnut',
icon: ''
}]
};
event.waitUntil(self.registration.showNotification("Hello world", options));
});