feat: enhance push notification service worker for chore expirations and update related configurations
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Failing after 2m22s
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Failing after 2m22s
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Service Worker for Reward App push notifications */
|
||||
/* Service Worker for Chorly push notifications */
|
||||
|
||||
/* Activate immediately — no waiting for old tabs to close */
|
||||
self.addEventListener('install', function (event) {
|
||||
@@ -16,18 +16,24 @@ self.addEventListener('push', function (event) {
|
||||
try {
|
||||
payload = event.data.json()
|
||||
} catch (e) {
|
||||
payload = { title: 'Reward App', body: event.data.text() }
|
||||
payload = { title: 'Chorly', body: event.data.text() }
|
||||
}
|
||||
|
||||
const title = payload.title || 'Reward App'
|
||||
const title = payload.title || 'Chorly'
|
||||
// Android Chrome has a bug where event.action is unreliable — only show Approve
|
||||
// so tapping it always executes the correct action.
|
||||
const isAndroidChrome =
|
||||
/Android/.test(self.navigator.userAgent) && /Chrome\//.test(self.navigator.userAgent)
|
||||
// Expiry-warning notifications are informational only — no action buttons
|
||||
const actions =
|
||||
payload.type === 'chore_expiring_soon'
|
||||
? []
|
||||
: [
|
||||
{ action: 'approve', title: 'Approve' },
|
||||
{ action: 'deny', title: 'Deny' },
|
||||
]
|
||||
: isAndroidChrome
|
||||
? [{ action: 'approve', title: 'Approve' }]
|
||||
: [
|
||||
{ action: 'approve', title: 'Approve' },
|
||||
{ action: 'deny', title: 'Reject' },
|
||||
]
|
||||
const options = {
|
||||
body: payload.body || '',
|
||||
icon: '/icons/icon-192x192.png',
|
||||
|
||||
Reference in New Issue
Block a user