Reputation: 6004
The Chrome Browser developer tools have under the application tab an option to test push notifications. I have a registered service worker running that can handle received push notifications but it doesn't receive any from it. How to test push notifications with it correctly?
Upvotes: 4
Views: 1127
Reputation: 596
You can use Chrome's DevTools to trigger push events with custom data:
(credits to: Umaar)
On recent versions of Chrome you can also inspect the service workers using the Chrome developer tools:
If your website sends push notifications, you should see at least one service worker that is registered and activated: a service worker, usually placed in the root directory, is always required in order to display the notifications received using the Push API. If you don't see a service worker, the push notifications won't be displayed. You can also inspect the code of the service worker by clicking Source.
Another interesting feature for inspecting the push messages received is the Push messaging tab located under Background services in the side navigation. It allows to see the push messages received by the service worker regardless of whether notifications are displayed or not. For example, if you don't handle the push event in the service worker, a push message can be still received successfully and is listed there, even if you don't see any visible notification. If you are debugging notifications on a website, this allows to understand if the problem is that your device is not receiving the notifications, or if the notifications are received but not displayed.
Tip: remember to click the Start recording events button to see the push messages, otherwise the list will be empty.
Lastly, you can try also the following two links for debugging service workers in Chrome.
chrome://serviceworker-internals/
chrome://inspect/#service-workers
In particular they can be useful to terminate the service worker or see console.log messages, errors, and whether the service worker code is updated.
(credits to PushPad)
Upvotes: 0
Reputation: 177
go test your code with edge devtools in this case; until chrome is update this bug.
Upvotes: -2