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

**URL:** https://community.thunkable.com/t/how-can-my-app-identify-changes-in-firebase-send-push-notifications-when-app-is-closed/1059222
**Category:** Questions about Thunkable X
**Tags:** firebase
**Created:** [January 20, 2021, 9:18am UTC](https://community.thunkable.com/t/how-can-my-app-identify-changes-in-firebase-send-push-notifications-when-app-is-closed/1059222 "2021-01-20T09:18:23Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![nicogregori](https://avatars.discourse-cdn.com/v4/letter/n/cab0a1/32.png) [@nicogregori](https://community.thunkable.com/u/nicogregori)
#### Post date: [January 20, 2021, 9:18am UTC](https://community.thunkable.com/t/how-can-my-app-identify-changes-in-firebase-send-push-notifications-when-app-is-closed/1059222/1 "2021-01-20T09:18:23Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)
#### Post date: [January 20, 2021, 10:17am UTC](https://community.thunkable.com/t/how-can-my-app-identify-changes-in-firebase-send-push-notifications-when-app-is-closed/1059222/2 "2021-01-20T10:17:54Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![nicogregori](https://avatars.discourse-cdn.com/v4/letter/n/cab0a1/32.png) [@nicogregori](https://community.thunkable.com/u/nicogregori)
#### Post date: [January 20, 2021, 10:37am UTC](https://community.thunkable.com/t/how-can-my-app-identify-changes-in-firebase-send-push-notifications-when-app-is-closed/1059222/3 "2021-01-20T10:37:37Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)
#### Post date: [January 20, 2021, 10:54am UTC](https://community.thunkable.com/t/how-can-my-app-identify-changes-in-firebase-send-push-notifications-when-app-is-closed/1059222/4 "2021-01-20T10:54:40Z")

</div>

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](https://firebase.google.com/products/cloud-messaging?&gclid=CjwKCAiAxp-ABhALEiwAXm6IyQd0CMDpodfigmJVuukHBqha6_82oZyWmSHXLHr5nhDUGgF8Gp9UAxoCXUEQAvD_BwE)

---

<div class="post-metadata">

### Author: ![retired](https://avatars.discourse-cdn.com/v4/letter/r/ce73a5/32.png) [@retired](https://community.thunkable.com/u/retired)
#### Post date: [January 20, 2021, 11:41am UTC](https://community.thunkable.com/t/how-can-my-app-identify-changes-in-firebase-send-push-notifications-when-app-is-closed/1059222/5 "2021-01-20T11:41:06Z")

</div>

I know I still have the same problem

---

<div class="post-metadata">

### Author: ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)
#### Post date: [January 20, 2021, 12:12pm UTC](https://community.thunkable.com/t/how-can-my-app-identify-changes-in-firebase-send-push-notifications-when-app-is-closed/1059222/6 "2021-01-20T12:12:48Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 1:30pm UTC](https://community.thunkable.com/t/how-can-my-app-identify-changes-in-firebase-send-push-notifications-when-app-is-closed/1059222/7 "2024-11-08T13:30:38Z")

</div>


