Reputation: 260
I have created web push notifications and they work in Firefox ok (service worker is registered, subscription created, subscription data stored, using subscription data notification is sent ok). I have tried the same in Chrome and Opera, but nothing happens. I tried to debug, and after I send push notification, browser receives it, executes code, but nothing happens. There are no errors, code runs till the end. Service worker code is the following:
'use strict';
self.addEventListener('push', function(event) {
console.log('Push started');
const promiseChain = self.registration.showNotification('Hello, World.');
event.waitUntil(promiseChain);
console.log('Push finished');
});
I see in console 'Push started' and 'Push finished'. Server uses https. Any ideas, what can be wrong?
Upvotes: 0
Views: 2178
Reputation: 554
After a short research I came to know that notification was blocked for chrome from system settings on macbook. Enabling notification for chrome from system settings works for me!
Try to enable for your browser and check again👍🏻
Upvotes: 0
Reputation: 347
I have configured SSL in my application and running it with https.Till i am not getting any notifications in chrome, but in firefox and edge its working.
Upvotes: 0
Reputation: 2727
A assume you have a development domain with no https. Google Chrome only sends notifications when running with configured SSL.
How to bypass: For local development you can launch Chrome with the unsafely-treat-insecure-origin-as-secure
option.
open -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
--args \
--user-data-dir=$HOME \
--unsafely-treat-insecure-origin-as-secure=http://your-insecure-domain.dev \
Upvotes: 1