Get the current users email subscriptions for a single forms app.
const formsAppId = 1
const emailSubscriptions =
await approvalsService.getEmailSubscriptions(formsAppId)
Check if the user is currently subscribed to notifications
const isSubscribed = await notificationService.isSubscribed()
// Allow user to subscribe or unsubscribe
Subscribe the current user to notifications
const formsAppId = 1
const isSubscribed = await notificationService.subscribe(formsAppId)
// isSubscribed will be false if user denied permission to push notifications
Subscribe the current user to notifications
const formsAppId = 1
await notificationService.unsubscribe(formsAppId)
// isSubscribed will be false if user denied permission to push notifications
Update the current users email subscriptions for a single forms app.
const emailSubscriptions = {
newApproval: true,
clarificationReceived: true,
}
const savedFormsAppUserSubscription =
await approvalsService.updateFormsAppUserSubscription(
emailSubscriptions,
)
Notification Service
Helper functions for notification handling
Service Worker
To display push notifications and allow them to be clicked to open the application, add the following JavaScript to your service worker (we recommend using offline-plugin):
Example