I managed to run a working example for sending web-push notifications - subscribe user for push notifications, get the endpoint, generate the two browser keys f
One of situations you will meet this error described following:
One will produce the wrong process
And Google tutorial also mention following:
open DevTools (Right Click > Inspect) and go to the Application panel, click the Service Workers tab and check the Update on Reload checkbox. When this checkbox is enabled the service worker is forcibly updated every time the page reloads.
If you want to push notification with payload in website:
Add applicationServerKey in when you subscribe
If you add applicationServerKey in when subscribe
Workable keys generator: Workable keys generator
Workable google tutorial: Workable google tutorial
Conclution
applicationServerKey and cause errorsWorkable keys generator but still errorsGoogle tutorial to update service worker to prevent some errorI managed to figure it out. And now I'm sending PUSH with payload successfully :)
The problem was that when I was registering for PUSH - I was doing it like this:
reg.pushManager.subscribe({
userVisibleOnly: true
})
When I did it like this:
reg.pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey: new urlBase64ToUint8Array([VAPID public key)
})
then it worked just fine. Now I'm able to send normal PUSH or PUSH with payload, with no problems.
More info:
And regarding all the tutorials that tells you to use only the userVisibleOnly property...that doesn't work. I don't know why they would be recommending this.