Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 966
Nicolas Rojo Avatar asked Aug 07 '17 20:08

Nicolas Rojo


People also ask

Does FCM work on Safari?

FCM doesn't support Safari browser.

How do I send push notifications in Safari?

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.

Can I use firebase for push notification to iOS?

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.

Does Safari support web push?

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.).


2 Answers

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.

like image 55
Frank van Puffelen Avatar answered Oct 24 '22 11:10

Frank van Puffelen


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().

like image 12
o4ned Avatar answered Oct 24 '22 10:10

o4ned