push-fcm-plugin icon indicating copy to clipboard operation
push-fcm-plugin copied to clipboard

Closing notifications on mobile

Open hb0nes opened this issue 7 years ago • 0 comments

Editing the .sw file to listen for clicks to close them does not work. Is there a way to make the notification redirect/close on click with this plugin? This is what my sw looks like now;

importScripts('https://www.gstatic.com/firebasejs/4.1.2/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/4.1.2/firebase-messaging.js');

if (firebase.apps.length > 0)
    firebase.messaging();

self.addEventListener('message', function (event) {
    if (firebase.apps.length === 0) {
        firebase.initializeApp(event.data);
        firebase.messaging();
    }
    event.ports[0].postMessage(event.data);
});
self.addEventListener('notificationclick', function (event) {
    console.log('Clicked');
    const clickedNotification = event.notification;
    clickedNotification.close();
});

hb0nes avatar Oct 28 '18 01:10 hb0nes