1

Please help me. I am using Cloud Functions for Firebase to write a back-end script for my Android application. This script is supposed to update a value in the Firebase Database once per day, at a specific time of the day, automatically.

The problems are:

  1. I managed to make the function be triggered when that value from Firebase is changed(with onWrite() event), but that's not really automatically.

  2. I couldn't find the best, or one of the best solution for the code, on how to specific the moment of the day when the value will be changed.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Razvan
  • 292
  • 2
  • 3
  • 15

1 Answers1

3

Instead of using a Database trigger, use an HTTP trigger with a third party cron job service. Check out these resources to learn more:

Timing Cloud Functions with HTTP Triggers and Cron

Cloud Functions Samples - Delete Unused Accounts Cron

Jen Person
  • 7,356
  • 22
  • 30
  • Thanks for help! I will try this way and come back after that – Razvan Aug 24 '17 at 17:20
  • Since that great video, I have been thinking on how to do it with out using a third party, and I have a really hacky way to do it. Using Firebase job dispatcher https://github.com/firebase/firebase-jobdispatcher-android you can make any Android device to do a cron job, you could set a firebase cron job to set a value in a node and listen to that with Functions... maybe leaving that device charging.... always... like a server... a very small server – cutiko Aug 24 '17 at 20:20
  • The answer is correct. Thank you again! – Razvan Aug 26 '17 at 16:07