Web Push API
The following methods can be used to manage the push subscriptions on the Web platform:
Subscribe
Use this method to subscribe for push notifications. This process will use the ServiceWorkerOptions provided in the Configuration.
await EngagementCloud.push.subscribe()
Unsubscribe
Use this method to unsubscribe from push notifications.
await EngagementCloud.push.unsubscribe()
IsSubscribed
Calling this method will return a Boolean indicating the subscription status.
const isSubscribed = await EngagementCloud.push.isSubscribed()
GetPermissionState
Calling this method will return a String indicating the permission status.
const permissionState = await EngagementCloud.push.getPermissionState()
The returned value will be one of these options:
- Granted: if the allowed push notifications
- Denied: if the user refused to receive push notifications
- Prompt: if the users decision is unknown