I Hafid
I Hafid

Reputation: 403

How to detect if push notifications are blocked on current website?

I am using OneSignal and want to be able to detect current subscribtion state between those three:

OneSignal API gives the isPushNotificationsEnabled function, but it only detects two states: pushes allowed or not.

I wonder if there's more general (outside of OneSignal API) method to detect that, at least in some browsers.

Upvotes: 8

Views: 4396

Answers (1)

I Hafid
I Hafid

Reputation: 403

Solution turned out to be Notification.permission, which takes three states:

  • default
  • granted
  • denied

And that's exactly what I needed.

Upvotes: 14

Related Questions