Step-by-Step Guide to setup WebPush notification in javascript websites like React, Vue, and Next.js.
Configuration
serviceworker.js
(mentioned in step2), you can pass name of it in swFileName
.Add ServiceWorker file
serviceworker.js
file such that it should be publicly accessible from https://<your_domain>/serviceworker.js
. Add below lines of code in that file and replace publicApiKey with key you find in API Keys page in SuprSend Dashboard.Register Push
registerPush
in your code, which will perform following tasks:Promise<ApiResponse>
NOTE: This method should be called on user action like button click for better UX, don’t call this on page load.