Push notifications in Apple Safari with FCM
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.
Safari doesn't support web push, which FCM relies on for browser support. So that means that Safari can't receive FCM notifications.
Safari still does not support Web Push API, thus Firebase Cloud Messaging service.
Here is supported browsers in Firebase: https://firebase.google.com/support/guides/environments_js-sdk#browsers
I'd suggest using .isSupported()
instead of other solutions.
if (firebase.messaging.isSupported())
const messaging = firebase.messaging();
}
See the documentation for details on .isSupported()
.