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?
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.
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().
I'm not sure about this new Safari and Service Workers situation, but I tried to implement FCM push-notifications in my iOS app and had to experience that you need an APN (Apple-Push-Notification) certificate first. I'm not sure if this is needed if you're working with Safari, but I could imagine that Apple also wants it's push notifications first to be redirected to the APN servers.
Apple says that Safari 16 (macos) should now support Push API but I didn't manage to make push API notifications work correctly. I tried firebase messaging web v9 (which should be a wrapper over Push API from what I understand) and it seems to work in background (when delivered by the service worker) but in foreground only receives notifications 3 times, then it stops working.
FCM doesn't support Safari browser.
If you want to integrate PUSH notification for Safari browser, follow this link. Safari has its own mechanism for it.
https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/NotificationProgrammingGuideForWebsites/PushNotifications/PushNotifications.html#//apple_ref/doc/uid/TP40013225-CH3-SW1
Related
I host a PWA website and I am trying to integrate push notifications to my users who may have the website open in a browser tab even if their phones are inactive. You notoriously can't send Push notifications to iPhones without using Apple Push Notifications service (APNs).
Seeing as the point of firebase cloud messaging (FCM) is to outsource the message handlers, I kinda assumed it would support sending push notifications to iPhones somehow via APNs, but the information here suggests you still can't do this from the web.
https://firebase.google.com/docs/cloud-messaging/js/client
Safari and iPhones don't support Push API.
According to this answer: https://stackoverflow.com/a/64576541/2116253
Option #2 may be possible if you know the device ID token, which is apparently very hard to get and perhaps not possible anymore because Apple are trying to make it harder to obtain due to security concerns.
I think the actual sending via APNs from server side is quite easy, the problem comes with the initial setup/registration and actually granting permissions that allow notifications to arrive.
So, in short, I don't mind registering my website with Apple, agreeing to terms and obtaining keys for the purpose of interfacing with APNs, but I don't want to make and distribute a whole native iOS app just to send notifications to devices about my website.
Does anybody know the correct way to achieve this in 2022 ?
I am trying to implement server for FCM to send notifications to android/iOS devices.
I need to send data-only notifications to both android and iOS but iOS seems very unstable for background notifications. (even though the app is in foreground, I often not get message at all.)
When I test with legacy FCM REST server with FCM direct channel, it works great on iOS but this is not an option for me as newer Admin SDK doesn't support direct channel.
Is there any reason to remove support for FCM direct channel in newer Admin SDK? I see all Firebase docs recommend to use Admin SDK but not sure why they removed the support for direct channel.
If I'm not mistaken FCM sender-side APIs never explicitly supported a direct channel option. As a sender your options were to either specify a device registration token or a topic. These options are present in the newer FCM sender-side APIs (i.e. Admin SDK) as well.
Direct channel is a receiver-end option. I see this option was recently deprecated in the iOS SDK. Folks who work on that repo should be able to provide you more context around that decision. Also if you're experiencing issues with background notifications on iOS I'd recommend you file a bug for the iOS SDK, and try to get it fixed.
We currently have a hodgepodge of messaging systems. For mobile we were using Ionic Push cloud service, and for desktop we are using socket.io+desktop notifications. We recently moved our mobile push notifications to Firebase cloud messaging. We want to move our desktop notifications as well. From the docs, it seems like FCM works with recent versions of Chrome and Firefox. Safari supposedly supports push via APNs.
Is it possible for FCM to use the existing desktop notifications for push?
Or maybe I can use FCM just to retrieve push notifications across all browser and then use the desktop notifications libraries myself to display the message. I'm just a little confused by the landscape of types of pushes to browsers and desktops.
I have looked into the documentation of FCM and it mentions that it cross platform. Anyhow FCM for Web documentation talks about Chrome. I want to check whether FCM supports messaging to all major web browsers including IE, Safari and Firefox?
The link you mentioned is talking about FCM support for Chrome apps and extensions only, it's a different story for the web.
FCM supports Web Push Protocol, according to this article: https://developers.google.com/web/updates/2016/07/web-push-interop-wins
Now that FCM supports Web Push Protocol you can leave the endpoint intact and use the URL as a Web Push Protocol endpoint. (This brings it in line with Firefox and hopefully every other future browser.)
You no longer need a Firebase project, a gcm_sender_id, or an Authorization header.
Both Chrome and Firefox use the Push API for push notifications and Firefox already supports Web Push Protocol, which means by updating FCM server-side code, it will work for both Chrome and Firefox.
Google really needs to update their docs as Enable Push Notifications for your Web App is out of date.
It won't work with IE and Safari as they don't support the Push API at all.
I am planning to build a "hybrid app" using PhoneGap which needs to have a iOS push notification engine.
And I want to use Google Cloud Messaging for sending push notifications to the iOS (I have used this for sending notifications to Android).
My questions here are:
Can I use Google Cloud Messaging for iOS in an hybrid app (using PhoneGap's https://github.com/phonegap-build/PushPlugin)?
Are there any changes that I may have to do while using the above plugin?
I have used the above PhoneGap plugin to receive notifications from GCM and APNS separately but this time I want to use the GCM for both iOS and Android.
Any help will be appreciated.
I also have used GCM and APNS separately for send push notifications to Android and iOs devices independently.
For all the documentation I've read, GCM for iOs devices is an approach of the APNS service but using the same structure that GCM is using for Android devices. I think that if you have used the APNService, you have found all the hard steps (certificates, using strictly a Mac for some things, ...) so, answering to your questions:
Yes, you can use the GCM for iOs with Phonegap plugin because GCM Server sends the data that PhoneGap's plugin is ready to receive (as you can see in the GCM Server Reference there are some data specific for APNS (nothing that you don't know if you have worked with APNS)).
If you are preparing a native app for iOs, you should see the GCM iOs Client documentation because you will have to use the iOs API but it's not your problem.
I don't expect that you have to do changes while using PhoneGap's plugin. You will only have to use PhoneGap's implementation for iOs devices and get ready to receive push notifications (but if you have some troubles, please, I will be pleased to know them).
Good luck!