I am trying to check if a function or method is being invoked in the server and act accordingly.
I am creating a basic app that notifies people about their financial transactions. I am using Flutter for the app, NodeJS for the server side of things, Firebase Cloud Messaging for Push Notification and React in order to send the data. So far, I've been successful in sending the Notification and displaying a list of notification for the user when using the mobile application. The whole system works something like this:
- The message is composed and sent from the react website,
- The website calls a POST request from the server to send a notification,
- The POST request then calls the
getMessaging()
function from the Firebase API that sends the notification to that device - The mobile application listens for a notification using
onMessage()
as well asonBackgroundMessage()
. When a notification is received it again calls the server to store some notification data to the database.
The reason I am storing the notification in the database after it is received by the device is so that I know the status of the message I've sent i.e. "delivered". Now, I am aiming to send an SMS to the device if the notification is not "delivered" after a certain period of time. However, looking at the workflow, sending the notification and storing notification are two complete separate methods and thus, I am out of ideas. Is there any way to know if a method/function is being invoked and act accordingly. Or should I take some other approach to this scenario? (If yes, could you give some ideas?)