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?
FCM doesn't support Safari browser.
To send a message to the Safari browser, you must specify the raw message content, and you must include a specific attribute in the message payload. You can do this by creating a push notification template with a raw message payload, or by specifying the raw message content directly in a campaign message.
For Apple client apps, you can receive notification and data payloads up to 4000 bytes over the Firebase Cloud Messaging APNs interface. To write your client code in Objective-C or Swift, we recommend that you use the FIRMessaging API.
Web push notifications have been existing on almost all operating systems (Windows, Linux even macOS on desktops and Android on mobiles) and almost all browsers (Chrome, Firefox, MS Edge, Safari, Opera, etc.).
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()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With