0

I've been struggling with the issue for a few days already.
I have an android app where the user specify how often a plant should be watered. I want to send a notification based on how often the plant should be watered. (e.g. send a notification every 3 days).
I know there are a bunch of questions addressing this issue, but I still couldn't make it work.
I started with implementing/starting a Service with an alarm manager.
The main issue is that once my app is killed, notifications are not sent anymore.
I am using firebase to store all the data.
I read something about firebase functions, but I don't know if this can be applied. I am storing in the database "how many days ago has the plant been watered" and how frequently should this plant be watered.

Thank you for your time.

S.Andreea
  • 1
  • 4

2 Answers2

0

You will need to use google cloud functions with a cronjob every 3 days, check this links

https://firebase.google.com/docs/functions/schedule-functions

and

Send push notifications using Cloud Functions for Firebase

Also, you can check the google cloud functions repo where you can find a detailed example

https://github.com/firebase/functions-samples/tree/master/fcm-notifications

Gastón Saillén
  • 12,319
  • 5
  • 67
  • 77
  • Thank you very much for your reply. I read about the schedule functions and it really looks like it's what I need, but it seems that I need to pay for it. Do you know if it's possible to do it for free? – S.Andreea Apr 11 '20 at 00:54
  • Yes, You can but is not gonna be that easy – Gastón Saillén Apr 11 '20 at 01:24
0

I found a solution here: https://github.com/fabcira/neverEndingProcessAndroid7- A process will be running constantly even though the application is completely closed (not just moving it to background) by the user. The process can be killed from "Running services" on your phone.
This solution is free.

S.Andreea
  • 1
  • 4