如何从Firebase浏览器推送通知中删除默认按钮

时间:2019-03-05 15:59:50

标签: javascript php firebase push-notification firebase-cloud-messaging

是否可以从Firebase浏览器推送通知中删除“激活”按钮?

enter image description here

下面给出了我的代码,我没有添加“激活”或“设置”按钮。我仅添加了“立即答复”按钮。

var messaging = firebase.messaging();

self.addEventListener('notificationclick', function (event) {
  // Notification click    
   if(event.action == 'reply_now')
   {
       clients.openWindow('http://www.example.com');
   }
});

messaging.setBackgroundMessageHandler(function (payload) {

    var noti = JSON.parse(payload.data.notification);    
    var notificationTitle   = noti.title;
    var notificationOptions = {
        body: noti.body,
        icon: 'https://www.gstatic.com/mobilesdk/160503_mobilesdk/logo/2x/firebase_28dp.png',
        actions: [
            {   
                action: 'reply_now',
                title: 'Reply Now',
                icon: 'https://www.gstatic.com/mobilesdk/160503_mobilesdk/logo/2x/firebase_28dp.png'
            }
        ]
    };

    return self.registration.showNotification(notificationTitle, notificationOptions);
});

0 个答案:

没有答案