How would I make an app to send a notification if it’s closed? I’m making an app that reads the data from the web server and I need to send the notification to the user only if the app is closed and the value on the web server is changed.
Asked
Active
Viewed 458 times
1
-
I'm sure you can find a lot of examples online. What have you tried and where are you stuck even after searching online? Post the logcat if you're getting any errors. – David Lee Jul 08 '21 at 22:24
-
Couldn’t find what I was looking for because all I can find are timed notifications and on-button click ones. – leeo6002 Jul 08 '21 at 22:44
-
Possible duplicate of https://stackoverflow.com/questions/39674850/send-a-notification-when-the-app-is-closed. – David Lee Jul 08 '21 at 22:46
-
If the payload only contains a data block and not a notification block, your app will be created and your fcm service will receive the payload and then you can do whatever you want – Amin Jul 09 '21 at 01:01
1 Answers
0
I have been struggling with this for a while, and finally I had to use Firebase Cloud Messaging.

AIMIN PAN
- 1,563
- 1
- 9
- 13
-
Sorry for answering late, but I implemented FCM into my app, and now my question is how would I automatically send a notification to a user if the variable on the webserver has changed and when the app is not opened. – leeo6002 Jul 12 '21 at 16:51
-
FCM is sent from server. You can implement a listener on your web server, if the variable changes then send the FCM notification. I did this with a go-lang webserver integrated FCM. – AIMIN PAN Jul 13 '21 at 00:05
-
Ok, but I don’t want to send a notification every time the state changes, I want to send the notification only if the app is closed. – leeo6002 Jul 13 '21 at 11:47