javascriptservice-workerweb-pushpush-api

How to do feature detection for Web Push?


Is there any easy way to feature detect Web Push API in browsers (Desktop and mobile)


Solution

  • Some browser versions support only the service worker but not the Push API.

    It's recommended that you try to detect the Push API itself.

    If you need to check the browser support in a synchronous way (i.e. without waiting for Promise), you can use this (copied from the Pushpad SDK):

    function isPushApiSupported() {
      return 'PushManager' in window;
    }