I am a newbie and I am working on a travel agency app in which I should update new trips offers every week and I don't know how to do this using firebase and what is the technique?
Asked
Active
Viewed 129 times
-1
-
Search about WorkManager https://developer.android.com/topic/libraries/architecture/workmanager – Elias Fazel Jan 31 '20 at 18:06
-
Does this answer your question? [Schedule a work on a specific time with WorkManager](https://stackoverflow.com/questions/50363541/schedule-a-work-on-a-specific-time-with-workmanager) – Elias Fazel Jan 31 '20 at 18:07
-
Since you want to update trip offers so, it seems like a backend server task. You can use **Cloud Functions for firebase** [https://firebase.google.com/docs/functions] for defining custom scheduled background task. – skWyz Jan 31 '20 at 18:11
2 Answers
1
As a shortcut, for small data sets, use Firebase Realtime Database.
Original answer:
I suggest using AlarmManager to schedule a system notification in the future. When Alarm is triggered it will wake up your application even if user wasn't using it (even if the phone is currently in their pocket). You will need to set up your app to be eligible to receive this notification and correctly handle it. In your case you would make a call to your API and update the trips in the background. Next time user interacts with your app they will see updated data without delay.

ermik
- 408
- 3
- 17
-
I got it but I have no idea how to update data to my app after launching it ? I don't know which feature should be used in firebase or what codes should be implemented in my project ? – Weam Feb 02 '20 at 01:20
-
(In your case you would make a call to your API and update the trips in the background.) Would you please give me more details ? – Weam Feb 02 '20 at 01:22
-
I can't give you the code to implement, it is specific to the use case. If you are looking for examples — check on Github or search for a firebase tutorial. I've added a link to Firebase Realtime Database in the answer which may help you resolve this quicker. – ermik Feb 07 '20 at 13:44
1
https://firebase.google.com/docs/functions/schedule-functions Blaze is required for this functionality though.

Troy Bailey
- 133
- 5
-
This would be a great back end solution for preparing the data that is being fetched by the client. – ermik Jan 31 '20 at 21:30
-
@Weam This answer only applies if you want to use Google Cloud Scheduler. You can still leverage a simple [cron job](https://firebase.googleblog.com/2017/03/how-to-schedule-cron-jobs-with-cloud.html) to fire a cloud function. – Jay Jan 31 '20 at 21:48