Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/lib/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ export const sendNotification = (title: string, body: string) => {
new Notification(title, options)
} catch {
try {
navigator.serviceWorker.ready.then((registration) => {
registration.showNotification(title, options)
Notification.requestPermission().then((result) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will trigger the permission request on start? If they reject, it's gone forever? Can we style the request with our own branding and text?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would
Ask permission only when user go in settings and enable. Eventually e can use the popup announcement or similar after user onboarded to ask for it (if installed as PWA)

if (result === 'granted') {
navigator.serviceWorker.ready.then((registration) => {
registration.showNotification(title, options)
})
}
})
} catch {}
}
Expand Down