I didn't got how to send notifications via API

So, I joined this community just today and I didn’t get how to send messages via API and I used the permission, messages sending button, and no errors in the console too!!
So, I need your help, can anyone assist me and let me know what type of error am I facing? I am just a bit confused and I can show my code snippet, which I used if needed.

1 Like

So, this is it, the code snippet

Hello @Krishna

could you send link to the topic

and check that your brwser does not block notification

and have a nice day

1 Like

@Krishna hi Krishna, and welcome to the community.

From your code snippet, it looks like you are trying to use a service worker to send notifications, but that won’t work unless you have got a service worker already registered and active on the web page.

I’m assuming that you just want to figure out how to send basic notifications, not tied to a service worker? In which case you need to use the basic Notifiations API : https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API

If I’ve got this wrong, and you are trying to do this inside a service worker, then my apologies!

1 Like

So, I tried to use the notification API but I want to include actions in my notification. So… I decided to use the service worker registration but I didn’t get how to register the service worker and If you need a link, I didn’t publish on Github and if you want me to publish, I will, and actually, I am new to notification API. Can anyone suggest to me which is best: One Signal or NOTIFICATION API and can teach how to use notification Api, and unfortunately I tried One signal but that gave hundreds of errors and I left it.

So, I was wondering, If I could know what this error mean by?!