Search code examples
firebasepush-notificationsafariapple-push-notificationsfirebase-cloud-messaging

Push notifications in Apple Safari with FCM


We implemented push notifications using FCM in chrome and firefox and it worked fine, but Safari doesn't support Service Workers which is mandatory for FCM.

Did anyone deal with this kind of issues? any suggestions?


Solution

  • While Service Workers now work on Safari, they are not enough.

    The documentation says:

    The FCM JavaScript API lets you receive notification messages in web apps running in browsers that support the Push API. This includes the browser versions listed in this support matrix.

    So the ability to receive messages through FCM depends on the browser implementing the Web Push API, which Web Kit does not.

    Safari is built on Web Kit, so doesn't support web push, so that means that Safari can't receive FCM notifications. All browsers on iOS devices are also built on Web Kit (as that is a requirement from Apple), so FCM won't be able to receive messages in any of them either

    If you want to test whether the environment your code runs on can receive messages from FCM, you can use this snippet of code:

    if (firebase.messaging.isSupported())
      ...
    }
    

    Update (2023-02-16): WebKit.org just announced support for Web Push in iOS/iPadOS 16.4 beta 1. We're investigating whether this also impacts Firebase Cloud Messaging's ability to deliver to devices with this version.