I make web app for restaurants. when client in restaurant on web page selects dishes, he clicks "order", and waiter will receive a push notificarion on his phone via fcm for web. Will waiter receive all notifications through fcm for web? I need them to be delivered in 2 minutes maximum, can firebase fulfill my requirements? Thank you
Realistically, most messages will be delivered in under a few seconds, assuming the target device is active and has a good network connection. In practice, there is no way to ensure the timing of the delivery of a message, as the network could be poor or missing, and the device could be in a battery-saving state the delays receipt. If you want to increase the chances of the message getting to the device, use a high priority notification, as described in the documentation.
Related
The logic of my project is that I have to send notifications from admin panel to users in web and mobile app at the same time! another meaning:
When the admin send a notification to John Doe I need John to receive the notification on website and mobile app at the same time!
Does FCM can do that ? or I have to send notifications for mobile app and do another thing for web to web which is admin to user on web??
FCM does not guarantee the timing of the receipt of messages. If you send two messages, they will very likely end up on the devices at about the same time, but there is no guarantee that they will. Also consider that one of the devices might not even be on at the time the message is sent - that message simply will not arrive until the device is turned on again.
But you can certainly write code to send as many messages as you need to as many devices as you want, and simply accept the results.
Yes, it's possible. That's the nice thing about Firebase services, so that you don't have to write entirely different code for the same functionality for each platform separately.
I am making a website and one of the features is that whenever a contract is nearing its end, the user should be notified about it. So I was looking for a way to notify users and I found out about push notifications.
Now, there are lots of things written about it. I heard a lot about Google Cloud Messaging, Firebase Cloud Messaging and Service Workers.
Now the thing is that my website will probably be on an Intranet. So maybe I won't be able to use GCM/FCM.
But I have a few questions regarding GCM, FCM and Service-Workers:
Why do I need FCM/GCM?
What is the difference between FCM and Service Workers?
Is there a way to push notifications even if the browser is closed?
Because my website is on an Intranet, is there another way to push notifications to the users?
1. Why do I need FCM/GCM?
You may check here the features of FCM.
Notification payload: 4KB, Message payload: 2KB. Note that the notification includes device and app information too.
Stores 100 notification/messages per device if the device is offline.
Stores notification/messages for 30 days if the device is offline, and deleted them all one this period is over and the device is still offline.
FCM supports Android and iOS devices, and even chrome web apps. The notifications are sent to iOS devices in this way: App Server -> FCM -> Apple Push Notification Server (APNs) -> iOS device -> App.
GCM supports 1 million subscribers while FCM do not have this limitation.
Supports programming in C++.
Less requirements for coding.
2. What is the difference between FCM and Service Workers?
Service Worker is a background service that handles network requests. Ideal for dealing with offline situations and background syncs or push notifications. Cannot directly interact with the DOM. Communication must go through the Service Worker’s postMessage method. Service Workers are pretty perfect for creating offline-first web apps. They let you interact with the server when you can (to fetch new data from the server, or push updated info back to the server), so your app can work regardless of your user’s connectivity.
While using FCM, you can notify a client app that new email or other data is available to sync. You can send notification messages to drive user reengagement and retention. For use cases such as instant messaging, a message can transfer a payload of up to 4KB to a client app.
3. Is there a way to push notifications even if the browser is closed?
Check this thread: Notifications while browser is closed
4. Because my website is on an Intranet, is there another way to push notifications to the users?
Unfortunately, I don't see any documentation regarding this.
Hope my answers help you.
I'm having trouble figuring out how FCM behaves when I send a notification to an iOS device that is offline (e.g. in airplane mode, or turned off).
The documentation on the time_to_live property mentions that Currently, time_to_live is not supported for notification messages on iOS. but doesn't provide an explanation of what is done instead. I've tried testing it, and it seems like a push notification sometimes goes through, and sometimes does not, regardless of what I set the time_to_live property to be, although I'm not sure if that's due to throttling or something else happening on the FCM side.
Relatedly, I can't seem to get the delay_while_idle property to work on iOS, although the documentation does not explicitly mention that it isn't available for iOS - notifications that are sent while the phone is asleep still wake the phone, even if I set delay_while_idle to be true.
Does anyone have any insight into how this is supposed to work?
The time_to_live is AFAIK applicable to both Android and iOS. However, since the process of sending the message to iOS devices for FCM goes like this:
App Server > FCM Server > APNs > iOS device
It is safe to say that only the FCM Server makes use of the time_to_live, as per it's description:
This parameter specifies how long (in seconds) the message should be kept in FCM storage if the device is offline. The maximum time to live supported is 4 weeks, and the default value is 4 weeks. For more information, see Setting the lifespan of a message.
Looking around, the behavior for APNs when sending to offline devices is (from the Apple docs):
Apple Push Notification service includes a Quality of Service (QoS) component that performs a store-and-forward function. If APNs attempts to deliver a notification and the destination device is offline, APNs stores the notification for a limited period of time and delivers it when the device becomes available again. This component stores only the most recent notification per device and per app. If a device is offline, sending a notification request targeting that device causes the previous request to be discarded. If a device remains offline for a long time, all its stored notifications in APNs are discarded.
As of now, delay_while_idle is now deprecated.
The way I know that you could do to wake up an iOS phone (online/connected to a decent network) is to simply set the priority to high.
I am working on my first Windows UWP app. And planning use Windows push notifications to notify the app about some server updates. This app will not have internet access always. It might be offline for couple of days. So I wanted to make sure whether I can use Push notifications in such a situation. When the notification is sent from the server if that device is offline, how long it will be there without being removed from the queue?
In a article I have read "By default, push notifications expire three days from the time that they are received by Windows Push Notification Services (WNS). If needed, you can override this default with an explicit expiration time." But I am not sure whether this is referring to what I am asking or whether it's saying that when it's delivered to the device, the tile, badge etc will remove that after 3 days.
Can you please clarify this.
By default, push notifications expire three days from the time that they are received by Windows Push Notification Services (WNS). If needed, you can override this default with an explicit expiration time.
I'm not sure where you've read this. However, this is not quite right. The three days expiration time refers to the lifespan of tile and badge notifications when they have been delivered by the device. It does not start from the time that they are received by WNS.
By default, local tile and badge notifications don't expire, while push, periodic, and scheduled notifications expire after three days. So in Expiration of tile and badge notifications, it says
By default, tile and badge notifications expire three days after being downloaded.
And we can change the expiration time for each notification by setting the X-WNS-TTL header. This header is uaually used if you want to ensure that your notifications are not displayed later than a certain time. The TTL is specified in seconds and is relative to the time that WNS receives the request.
For your question, from the Important notes under Sending a notification in Windows Push Notification Services (WNS) overview, we can find that:
When the device is offline, by default WNS will store up to five tile notifications (if queuing is enabled; otherwise, one tile notification) and one badge notification for each channel URI, and no raw notifications. This default caching behavior can be changed through the X-WNS-Cache-Policy header. Note that toast notifications are never stored when the device is offline.
And in X-WNS-Cache-Policy header, we can get more information.
When the notification target device is offline, WNS will cache one badge and one tile notification per app. If notification cycling is enabled for the app, WNS will cache up to five tile notifications. By default, raw notifications are not cached, but if raw notification caching is enabled, one raw notification is cached. Items are not held in the cache indefinitely and will be dropped after a reasonable period of time. Otherwise, the cached content is delivered when the device next comes online.
So when your app is offline, WNS can cache some push notifications for you, but it's hard to say how long they will be cached.
WNS responds to indicate that the notification has been received and will be delivered at the next available opportunity. However, WNS does not provide end-to-end confirmation that your notification has been received by the device or application.
WNS does not guarantee the reliability or latency of a notification. If you want to make sure users can be notified about the server updates, you may need to use some other techniques. For example, you can send an active request to the server for the server updates when the app is online.
The idea of using the push notifications is only to have a notification mechanism that will send a notification when there is a new message waiting to download from the backend service: all the notifications are of the same type e.g. "refresh messages from the server" (the same for Android and iOS).
Are there any limits for the Apple/Google push notifications services?
Assuming that my application will handle more that 100k active users (or even 1M or more users) - would there be any problem with the Apple Push Notifications or GCM services?
If using the push notifications for such a service is not a good idea then what is other solution that could be used for mobile chat applications?
Don't forget that on iOS user may forbid sending notifications, so your app won't receive any even in foreground. Thus, you need to implement your own push mechanism.
Need for push notifications
Especially on iOS you don't have a choice but to use their push notifications service APNS. There is no other way to receive notifications immediately because iOS may kill or neglect the TCP connections of your background app.
On Android it seems possible to use your own background TCP connection to avoid having to use push notifications. But you may still consider the use of the push notifications through GCM for the sake of improved battery usage.
Pricing
Neither APNS (iOS) nor GCM (Android) charge you for the service and you are allowed to send an unlimited number of messages.
Limitations and Requirements
Both services will delete message, when there are too many messages accumulated in the queue for an offline device - which makes sense because there is no point in delivering those messages hours later. You have to take that in to account, when writing your app (just do a poll when going back online).
Depending on the app you are writing, there may also be privacy concerns. Even if you encrypt the message itself, at least Apple/Google know when a notification is sent to a certain device, which may be a deal-breaker for certain high-security applications.
You will also need a server that is able to communicate to both APNS and GCM. There are open source solutions for that (e.g. easyApns for iOS and python-gcm for Android), but how easy their integration is depends on your server and the language it is written in.