I am starting with the Gmail push notifications. I have a process with the following logic:
Call the watch api and store the historyId (this is done once)
When I receive a new notification, call the history list api with the last stored historyId
Once the messages have been retrieved, update the stored historyId with the notification historyId
The documentation recommends renewing the watch every day. What I am unsure about is do I need to store the watch response historyId every time I renew the watch?
Related
I want to send FCM to everyone who installed the app. Is it essential to get everyone's tokens from the database every time?
My app is using firebase firestore overall. If there are 100,000 users,
do I have to read 100,000 from database to send fcm each time? (I think it`s little heavy stuff isn`t it?)
another workroad exists?
I wonder Is the only way to send it by putting it in the registration ID?
And can you send it on time? All apps on the market send push messages on time, but if you read 100,000 and send fcm separately, shouldn't it arrive like this at 9:01 or 9:02? But why do I always get messages at 9 o'clock?
What are the methods, logic, algorithms they use (the way companies usually use)
I still have no clue at all.
There is no "send to all users" operation in FCM. You either will have to send to each token (that's not a heave operation for FCM, which handles billions of such calls every second), or you have to subscribe all instances to a specific topic and then send to that topics (which ends up the same behind the scenes, just with Firebase loading the tokens for the topic for you).
This has been covered a few times before, so I recommend checking:
How do you send a Firebase Notification to all devices via CURL?
How to send notifications to all devices using Firebase Cloud Messaging
Firebase Cloud Messaging - Send message to all users
The notifications panel in the Firebase console has an option to deliver messages at a specific time, but no such option exists in the Firebase Cloud Messaging API. You'll have to either implement your own mechanism to schedule the delivery, or you can deliver a data message right away and then only display the notification on the device when it's time.
This also has been covered a few times before, so check:
Firebase Messaging FCM Distribution over configurable time interval
How can scheduled Firebase Cloud Messaging notifications be made outside of the Firebase Console?
Flutter Firebase Messaging: How to send push notifications to users at specified time
I previously used different push notification provider (they did not use VAPID keys) and got users subscribed to the service. Now, when I switched the push notification provider I'm in a situation where I kinda lost all previous subscribers, because they will not get the permission window again as they have already agreed to receive notifications. Is there a way to automatically update(re-subscribe?) the subscriber as he visits my webpage with a VAPID key pair so the "old" subscribers can still receive my push notifications?
Me again, I found that if you get the subscription with getSubscription() and then use the unsubscribe() function followed by another subscribe() function, you "update" the subscription and everything works without user interaction. The only real "issue" is that you can only update the subscription if the same user visits your page again.
Using cloud functions, how to send an FCM notification on a specific topic at a scheduled time of recipient time zone?
I can see that option in notification composer in firebase console, but is there any helper method to send it through code?
I have successfully implemented HTML5 Push Notifications for my site, for news updates and user events. If an endpoint is no longer valid (for whatever reason, but generally because a user revoked permission in their browser) I get a 404 or 410 status from the push server when I try to send a notification. Then I remove that endpoint from my records.
But what I would like is to be a little more proactive and check if an endpoint is valid, so my stats of subscribed users are more realistic and are not updated only when a notification fails to send (which could take days or weeks).
I thought of sending an invalid push message (for example with the wrong VAPID keys) but I don't have the guarantee that a server would check the validity of the endpoint before the validity of the payload, so even if this worked it could break in any moment.
Is there any more elegant way that I could do this?
We have an API to fetch the latest transaction data of the user based on the scheduled Next_Refresh_Time. Each user has different scheduled refresh time. Since we have thousands of users we have to run the scheduler to fetch the data. Please suggest me the best way to do it.
Each user has different scheduled refresh time. Since we have thousands of users we have to run the scheduler to fetch the data.
You could add a queue message and specify initialVisibilityDelay with Next_Refresh_Time value when a user login, and then you could create and run a Queue-trigger WebJob to process queue message and featch the latest data (and if current user is still online, add the message (specify same content and initialVisibilityDelay as original message) to queue).
Besides, if you’d like to real-time push the latest data to specific connected user, SignalR would help you implement real-time functionality and SignalR can be used in a variety of client platforms. You could save connection id of a login user in queue message, and then you can call hub method in WebJob function to push data to a connected user based on connection id.
The following thread and article would be helpful to know how to establish connection and call hub method.
SignalR - Broadcasting over a Hub in another Project from outside of
a
Hub
Hubs API for
SignalR