Firebase messaging not triggering onResume / onLaunch properly - firebase

There are no problems with the code, because if I press on the notification it triggers onResume, however if the app it's killed or the user deletes the notification no callbacks are triggered.
Right now I'm saving notifications locally on an SQL db, so when a user logs in back it shows how many notifications he hasn't read. However, If I can't trigger no callback when he deletes the notification or when the app is killed (Actually when the user logs in back, after a couple of seconds onMessage is called with the notification sent while the app was killed, however this still bothers me 'cause I can't get user's attention with notifications) I can't save them locally and when he logs in back in the app, those notifications that he dismissed won't ever be back.
Is there a way to callback a function when the user dismisses notifications or when my app is killed?

Basically as you know, notifications are designed to be removed by users.
So if you want users to see all the notifications from your service, you should consider with another UX something like notifications tab (Facebook, Instagram has)
And, manage all notifications from the server, set flag if it is been activated or not.
As far as I know, there is no callback when the user dismissed the one.
I hope it can help you to decide your service design.

Related

How to send a push notification to pwa from a nodejs server?

I have a working PWA application and i have tried integrating push notifications to it which worked. But those notifications happened totally in the front end, a user has to click a button and a push notifications would show up.
In my application i have a cronjob that runs every night to check if certain things are updated. If so i want to send a push notification to a user to notify them.
But i cannot find any information regarding this subject so I'm thinking it's not possible since the nodejs server doesn't have a connection to the PWA. Is there something I'm overlooking on my approach or is it simply not possible?

For a simple chat functionality why should I use something like Firestore when Push Notifications might be enough

In this simple scenario, why would someone choose to pay for a realtime service like Firestore for delivering latest updates, when a system based on Push Notifications can work as good?
If the user is not in the app, you can refresh the page as soon as the user taps the notification or opens the app. When the app is open you can refresh when a data notification is received.
What am I missing?
Why should anyone use something like Firestore when Push Notifications seems to be enough?

How to handle FCM subscribeToTopic and unsubscribeFromTopic with Flutter

I am developing an app for which I use firebase as the backend. I am using FCM to send notifications to my users, however, I am not yet grasping how to use subscribeToTopic and unsubscribeFromTopic.
My use case (which I do not know how to get it working):
After a user installs the app, he will be subscribed to the main topic of the app (I have this working). The user could then go to settings to unsubscribe from the main topic (I do not have this working).
The struggle:
All the different tutorials I find describe how to subscribe to a topic, they call subscribeToTopic('some topic') in initstate of the welcome screen. Is it required to do this everytime the app starts? What happens when the user calls unsubscribeFromTopic('some topic') and the next time they start the app subscribeToTopic('some topic') is called again in initstate?
My idea: first time the app is loaded I call subscribeToTopic('some topic') and never again. Then in the settings screen a user can unsubscribe (and subscribe). Does this work? What should I pay attention to?
Thanks in advance for helping!
You check if the app is launched for the first time by either using shared_preferences which stores this information locally or by storing a variable on Firestore that tells you if the user has logged in to the app before.
You subscribe to the topic if it's the first time and if it's not, you do not subscribe.
The first time you open the app show a welcome screen or something like that, where you ask the user to receive notifications or not (which is always more user friendly).
If the user continues you save this value in a local database like shared preferences or hive.
If the user subscribed you call the subscribe to topic method
If the user does not subscribe ofcourse you do nothing.
Then on the settingspage:
Show a switch which value is gathered from the local database you already defined.
When the user taps the value is stored, based on this value you subscribe or onsubscribe.
This is how I have done it in my app where I also use topics instead of tokens.

FCM method to determine if token/user has disabled push Notifciations

I know there are methods to check both iOS and Android to see if the user has locally disabled push notifications for an app, that is done within the app itself. But if a user disables push notifications for an app is this reported back to FCM? Does FCM know not to send a notification to that user and if so, is there anyway of pulling that info out of FCM.
The reason for this question is if the user hasn't used the app in a while and they disabled push notifications - without the user starting the app (thus getting updated tokens/checking for permissions) there is no way to know the user disabled push notifications - unless we can extract that from FCM.
And along these same lines, if a user has uninstalled the app, does FCM get updated that the token is now invalid due to app removal and removes it from its db - and if so, is there anyway to way to extract this from FCM?
In both cases, we need to either update our DB that the user has disabled push notifications (and possibly use alternate communication methods) or mark the user as 'uninstalled' and thus remove that user from any app communication method (fcm, sms, email).

after user went offline still it shows typing notification in ejabberd

i am using ejabberd server for chat application. The scenario is user A and user B doing chat. user B goes offline and then come online. user B get the all message with push notifiacation. But the issue is when user B goes offline still user A get typing notification from ejabberd. anyone can help me in this. It there any feature in ejabberd to handle this notification or i have to use filter and client side.
Typing notification is defined in XEP-0085: Chat State Notifications. It is purely client-side.
Clients are supposed to send update about their own state, but of course, the right thing to do for a receiving client is also to dismiss the typing indication when a resources get offline.

Resources