Integration steps of webpush in react application.
Integration of SuprSendProvider
vapidKey
prop to SuprSendProvider
. You can find it in SuprSendDashboard --> Vendors --> WebPush
.Add ServiceWorker file
serviceworker.js
file such that it should be publicly accessible from https://<your_domain>/serviceworker.js
. If you want to customise this default service worker file name serviceworker.js
to other file, pass swFileName
prop to SuprSendProvider
. Add below lines of code in that service worker file and replace YOUR_PUBLIC_API_KEY
with key you find in API Keys page in SuprSend Dashboard.Accessing webpush methods using useSuprSendClient hook
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.