Firebase Cloud Message difference between send to Tokens and Notificartion keys - firebase

I know the HTTP v1 APIs are not support device group managment, And I am consider using only HTTP v1 APIs for reduce project complexity.
As far as I know from github issue:
Send to all tokens instead of device group will work for a small
number of device tokens. But it won't scale for large groups
But I don't know what is the limitation of send to mutiple tokens and Notificartion keys?

Related

Expo how to manage a thousand FCM token for Push Notification?

I made an app that wants to blast (thousand users) notification using expo-notifications, like expo docs said https://docs.expo.io/push-notifications/sending-notifications/#http2-api, I send POST request to https://exp.host/--/api/v2/push/send, but when I tried to implement it on the server, it takes minutes to process it, because there are too many FCM token in the database. The reason why I didn't use some SDK like on the link before because my BackEnd used languages that not listed on the expo docs. How can I achieve that?
There are multiple things you can ensure you're doing to be sure you're sending the notification requests the right way.
Are you sure you're using to argument as an array containing multiple tokens instead of firing multiple HTTP requests to the same endpoint? Sending thousands of HTTP requests instead of one with multiple tokens may take significantly more time to finish.
Are you using GZip compression on the requests? As per the documentation
This can greatly reduce the amount of upload bandwidth needed to send large numbers of notifications.
As far as I know:
Expo servers can handle thousands (duh, millions) of notifications easily.
a request to exp.host/…/send doesn't actually wait for the notification to be sent, it's only a "put the notification on the queue", so there's no reason for the request to take any long time.
Another question I'd have is what language, library are you using on your backend and how are you sending the request to the Expo servers? Maybe there's some problem?

Firebase Cloud Messaging: Device Group sending support in Firebase Admin SDK

I'm struggling to find an answer on if Firebase Cloud Messaging supports sending notifications to Device Groups in the v1 HTTP API.
According to the migration documents, sending to device groups is supported.
Caution: Any apps that use device group messaging must continue to use the legacy API for the management of device groups (creating, updating, etc.). The HTTP v1 can send messages to device groups, but does not support management.
The important part being "HTTP v1 can send messages to device groups"
I'm using the firebase-admin-python SDK, and when sending a single or set of batch messages I get a successful response, but the push notification does not send.
Is sending to device groups actually supported by the SDK in the same way that firebase_admin.messaging.send and firebase_admin.messaging.send_all are? The statement above leads me to believe that they are, but pushes aren't delivering (they do deliver when using the older legacy FCM API)
I assume you mean the token parameter. There's no sparameter named to on Message.
The documentation you're quoting is for the HTTP v1 API. And it might very well support sending to device groups -- although I haven't been able to find any examples to confirm that. But I know for sure that the SDKs (all expect the Node.js SDK) neither expose nor support any functionality for sending to device groups. Docs at https://firebase.google.com/docs/cloud-messaging/send-message outline all the different ways you can send a message using the Python SDK, and it makes no mention of sending to device groups. The Message.token parameter must be given an individual device registration token.
It is however rather strange that the FCM backend does not return an error when passing a device group key as the token. I'd recommend reporting a bug for that.

Does Firebase Cloud Messaging have an option to limit maximum no. of notifications sent per user per day?

We use FCM to send app notifications. Basically, we want to put a cap on maximum number of notifications that an app user can get in a day. Does FCM have an option where on hitting the cap, the subsequent messages are discarded by FCM and not sent to the user?
FCM is a free service which currently doesn't have any limitations whatsoever when it comes to the count of notifications sent and received.
If you want to enforce a limit of some sort, you would have to enforce this on your implementation (probably server side), by preventing further messages when a specific range is hit.
In general, push notification features are good for letting users know of specific (non-critical) information. I don't get why anyone would limit something when it's already free of use -- unless there's some different cost you're limiting which is directly affected by the push notif service.

Firebase Cloud Messaging (FCM) - HTTP V1 API or Legacy HTTP API?

Our goal is sending notifications to groups of devices from our backend, and only from server side is possible to know which device should receive the notification.
We've done some attempts with AppCenter because we mostly work with Xamarin iOS/Android/Forms, but now we have the doubt that it's probably better to use directly Firebase API because wider and more powerful.
I see that with new version of API (HTTP V1) is not possible to send a notification to a list of tokens, feature that was available in legacy API using registration_ids parameter (https://firebase.google.com/docs/cloud-messaging/send-message).
Device group name (legacy protocols only)
I cannot use topics because when it's time to send the communication is a server's responsibility to prepare the "mailing list" for notifications.
I was thinking to use device group messaging (https://firebase.google.com/docs/cloud-messaging/android/device-group) but these are part of the legacy api, and I'm not sure if it makes sense/it's possible to use them with new version of API.
Is an option to send a batch of 100-200-500 push notifications each one to only one token? In theory there isn't a limit to notifications which is possible to send, but I'm worried that sending too many of them I could risk to be banned.
Is it better to use legacy API? Also AppCenter (Microsoft) uses legacy API, it's evident because of how the setup works and because from AppCenter's console it's possible to send notifications to a list of tokens, feature unavailable on Firebase's console.
Another person just asked something similar but the answer was to use topics (How to send firebase notification for all user at a time?).
Got here from the link in your comment in my answer here. And just to reiterate my response there, when sending messages to multiple tokens with v1, the suggested approach now is to use Topics Messaging, since registration_ids is not supported.
Is it better to use legacy API?
v1 was described as the more secure, cross platform, future proof way of sending messages to FCM clients. More secure since it uses OAuth2 security model.
However, if your use-case is better with using the legacy API, then I suggest you go ahead with using it.
This page suggests that you should stay with the legacy API if you want to continue to use the multicast feature: https://firebase.google.com/docs/cloud-messaging/migrate-v1
Any apps that use device group messaging or multicast messaging, however, may prefer to wait for future versions of the API. HTTP v1 does not support these features of the legacy API.

How can I create push notifications to a phone application from a server for a single targeted phone (cross platform)?

So my requirements in mind are I have an application continuously running on a phone and I need to be able to push events to this application from time to time.
The application will primarily pull data from the server but sometimes the server will have urgent data it needs to send to the phone. I also have as a requirement to send the notification to a very specific phone, which the application will have a unique identifier associated with that phone. So I'm not looking for a simple broadcast solution.
Polling a web service by the application on a frequent time interval seems like it would impact a data plan too much, plus battery usage of the device. So I'd like to avoid a polling solution if possible.
What would be a good way to accomplish this?
I recently used PubNub to send push notifications to a web app in lieu of Web Sockets. PubNub has SDKs for all sorts of languages. Their long polling method is extremely fast and efficient. You can map messages to different devices based on the UUID of the channel. At first it seems like a simple broadcast solution (and Pubnub can be used this way), but we were able to create unique sessions with a relative amount of ease.
http://www.pubnub.com/developers/
I do not quite understand if you want to build the application yourself or if you are looking for one.
I use Pushover to do this. Pushover runs on Android, iPhone, iPad, and Desktop. It supports multiple message priorities. You can do a http POST with a unique ID and message to send a message to a unique device.
Pushover has it's own API and is really easy to use.
Polling can indeed be costly in terms of data and battery. The most efficient way to send data from the server to a phone is using Push Notifications (iOS) or Google Cloud Messaging (Android). Both notification types can be implemented directly by the developer or by making use of an API.
Golgi is an SDK that produces custom type safe communication APIs. The APIs produced have full support for both Push Notifications and Google Cloud Messaging.

Resources