How can my app identify changes in Firebase & send push notifications, when app is closed?

People,

I need some help!

In my app users can create an account and save preferences on information they want to receive via push notification (onesignal). The information of each individual user is saved to firebase with a corresponding RealtimeDB listener.

Firebase is linked to a script that I deployed, which updates information in firebase, based on each user’s preferences. Every time the information changes in firebase (“When RealtimeDB Data changed, do …” - block) I want to send the user push notifications.

The problem is: The “When RealtimeDB Data changed, do … - block” only activates when the app is opened.

Any ideas on how my app can realize that information is changed in the DB even when it’s closed - And then send push notifications?

  • I already tried to use cloud variables, but diddnt find a solution there.

I had this problem with my messenger.
Problem: user A (app open) sends a message (i.e. changes realtime db) to user B (app closed). How do you notify user B of the message?

My Solution:
When user A sends a mesage, User A’s app also queries the realtime db for all users who should be notified of the message and sends them a one signal push notification.

The key is that in some cloud-based storage you need a list of everyone to notify (chat group, user group, etc).

I think the problem in my case is that the change is triggered by an external script. Thereby, my app doesn’t realize the change until it queries it when opening the app.

Consider 1) have the external script send a REST API call to one signal or 2) create a listener app running on a server somewhere that monitors for changes and sends notifications.

If none of these work, you might also consider firebase messaging Firebase Cloud Messaging | Send notifications across platforms for free

I know I still have the same problem

Yep, no simple solution since thunkable only runs when it is the active app.