self.addEventListener('push', function (event) {
    console.log('[SW] Push received');

    let payload = {};

    if (event.data) {
        payload = event.data.json();
    }

    const title = payload.title || 'New Notification';
    const options = {
        body: payload.body || '',
        icon: payload.icon || '/pwa-192x192.png',
        data: payload.data || {},
    };

    event.waitUntil(
        self.registration.showNotification(title, options)
    );
});
