pusher / push-notifications-web

Beams Browser notifications
MIT License
39 stars 20 forks source link

[Feature Request] isSupported as a function #101

Closed natoehv closed 2 years ago

natoehv commented 2 years ago

Hi all, when we use the Client constructor we have to enclose it in a try/catch statement, so it would be great if we could ask for the beams support before creating the instance, something like this:

import * as PusherPushNotifications from '@pusher/push-notifications-web';

if (PusherPushNotifications.isSupported()) {
  const beamsClient = new PusherPushNotifications.Client(...)
  ...
}

in that way, we can avoid using the try/catch statement, and we could use it in others places to take different decisions.

greetings!

benjamin-tang-pusher commented 2 years ago

Thanks for the suggestion. We will add this to our feature request list. I will close this issue as it is not a bug.