You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NOTE: Push Notification only works on deployed website
Push Notification functionality works BUT:
It can only send notification to 1 user
it's currently a backend route, we want to make it a function that send notification everytime there's a New Post
TO FIX: we need to store users' subscription key(will talk ab this more in section below) in DB to query and send notification to all users that subscribed.
Would recommend watching this Video before starting to look at the instruction below as it helps you understand some concept of Push Notif in Web
Description
Would recommend watching this Video before starting to look at the instruction below as it helps you understand some concept of Push Notif in Web
Access our current TEST push notification :
Go to zotnfound.com/playground:
components/Playground.jsx
Open your console in inspect
Click
register for push notification
121
triggers functionregisterServiceWorker(line 25)
to register serviceWorker (this allows push notif)Click
subscribe for push notif
126
triggers functionsubscribeUser(line 42)
to ask client for push notif permissionOnce clicked subscribe, it will print out a json IN CONSOLE that looks like this {endpoint, p256dh, auth}
Once you copied the key and save it in a safe place, Run our ZotNFound backend locally (on branch
webpush-api
)Replace
subscription
value (Prev req.body) with that key (this will allow server to send notif to the subscribed browser key upon using the route)Open Postman
Run
POST localhost:3001/notification
you will receive a push notification (let me know if you got any problem)
To Do:
push notification Function
that take in an array of keys to send notifs to all of themPOST /items
so that it can retrieve an array of keys from db and use thepush notification Function
to send notifsResources:
The text was updated successfully, but these errors were encountered: