Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Cloud Messaging doesn't work on chrome (iOS)

I've just started testing Firebase for website push notifications. The basic code seems to work perfectly well on many Android-based browsers (Chrome, Firefox...) apps but not those installed on iOS such Chrome on my iPad or iPhone. I couldn't find any information related to this issue. Am I missing something?

firebase.initializeApp(config);
const messaging = firebase.messaging();

messaging.requestPermission()
.then(function () {
    console.log('Notification permission granted.');
    // TODO(developer): Retrieve an Instance ID token for use with FCM.
    // ...
})
.catch(function (err) {
    console.log('Unable to get permission to notify.', err);
});
like image 222
Gloria Avatar asked Sep 06 '17 09:09

Gloria


People also ask

Does firebase cloud messaging work on iOS?

Stay organized with collections Save and categorize content based on your preferences. For Apple client apps, you can receive notification and data payloads up to 4000 bytes over the Firebase Cloud Messaging APNs interface.

Does iOS Chrome support push notifications?

You can set up Chrome to get notifications, like meeting reminders, from websites, apps, and extensions. If you get pop-ups or ads, learn how to block or allow pop-ups. Chrome doesn't get notifications on your iPhone or iPad.

Can I use Firebase for push notification to iOS?

Firebase Cloud Messaging integrates with the Apple Push Notification service (APNs), however APNs only works with real devices.

Does firebase messaging work on iOS simulator?

Does Firebase messaging work on iOS simulator? FCM via APNs does not work on iOS Simulators. To receive messages & notifications a real device is required.


2 Answers

Chrome on iOS is built on top of the same basic web view as Safari. Since that underlying component doesn't support Web Push, FCM push notifications cannot be delivered to Chrome on iOS.

like image 169
Frank van Puffelen Avatar answered Nov 13 '22 07:11

Frank van Puffelen


For future reference, if you get a blank page on your website on iOS browsers. just wrap your server worker in an if statement by checking if FCM is supported in that browser firebase.messaging.isSupported()

if (firebase.messaging.isSupported()) {
    firebase.initializeApp({
        'messagingSenderId': 'your code here'
    });
    ...
}
like image 44
Nadhir Falta Avatar answered Nov 13 '22 07:11

Nadhir Falta