This question already has answers here:
Cloud Functions for Firebase trigger on time?
(3 answers)
Closed 3 years ago.
I use Firebase cloud functions and it has worked well so far.
However, my app has a new feature that requires setInterval.
More specifically, the feature consists of simulating geo-coordinates of a fleet of cars based on their direction and velocity which varies over time.
Every 5 seconds, I calculate the new coordinates and update the firebase real-time database.
I have already written the code using setInterval and it runs in NodeJs on my local machine. But I just discovered that Firebase will kill my code after 9 minutes.
What can I do ?
Why not have the client side update a trigger document every X minutes to keep the function firing?
Related
This question already has answers here:
Is it safe to expose Firebase apiKey to the public?
(10 answers)
Should I hide firebase api keys into backend? Not due to data security but project cloning issue
(2 answers)
Closed 2 years ago.
I have been messing around with Firebase in a web app and realized there's something I don't understand.
In order for the JS code to send data to the Firebase servers, your apiKey has to be in the JS. But then that means your API key is public, and anyone using your website can inspect the code and just send arbitrary commands to Firebase on your behalf from the dev tools, or from any other site now that they have the API key.
I know I must be missing something, since this would make Firebase not useful. What is it I'm missing? What prevents users from sending arbitrary commands to Firebase with your ApiKey?
This question already has an answer here:
How to create cron jobs in firebase programmatically
(1 answer)
Closed 2 years ago.
Does anyone know how can I set up Cron Jobs dynamically with Firebase? I want to build a rule engine using which the Client can specify the rules, actions, and schedule and based on that I need to schedule that particular rule. Since the scheduling is in the hand of the Client. I can set a predefined frequency for the JOB.
I know in Node.js I can do it with libraries like "node-schedule". But since the Client strictly wants to use Firebase and Angular. I can't use that solution
There is no way to dynamically create schedule functions with just Cloud Functions.
The two most common approaches are:
Have a regularly scheduled Cloud Function (say every minute) that then reads the tasks from a database, and executes the tasks that are up.
Use a separate scheduler service that has an API to create schedules, like Cloud Tasks. Doug wrote a great article about that in How to schedule a Cloud Function to run in the future with Cloud Tasks (to build a Firestore document TTL).
Also see:
How to create cron jobs in firebase programmatically
This question already has answers here:
Cloud Functions for Firebase trigger on time?
(3 answers)
Closed 4 years ago.
I want to automatically update a child value in firebase database, monthly.. How can I handle this?
There is nothing built into the Firebase Realtime Database to automatically update values periodically. So you will have to write the code for this yourself.
After you write the code you will need to run that code periodically.
If you put the code into the app, you can run it periodically there. It's technically possibly, but a bit involved (is the app running all the time?, what if multiple users run it?, etc).
So the more common approach is to run that code on a server. If you don't have a server yet, you can run the code in Cloud Functions for Firebase, which allows you to run small pieces of (for now only JavaScript or TypeScript) code on Google's servers. To trigger this code to run monthly, see Cloud Functions for Firebase trigger on time?
There is nothing fully integrated at the moment.
One way would be to use a Google Cloud scheduler job that will start your process in a Google Cloud function once a month.
You will only pay once a month for the duration of your function.
You can have an example here
This question already has answers here:
Cloud Functions for Firebase trigger on time?
(3 answers)
Closed 5 years ago.
I would like to use Firebase to send reminder messages to a user device, e.g. a push notification (or email) at 3 PM.
Does Firebase come with a build in option for such a use case?
you can use firebase-could-function to send the notifications to users , and then setup cron job to trigger your function at the time you want with the period you want
This question already has answers here:
Delete firebase data older than 2 hours
(5 answers)
Closed 2 years ago.
I want to clear data from Firebase database every 24 hours, but I do not want to do this from code in my project, but from the Firebase.
Do firebase have such functions?
Yes it does. Please use the functions from Cloud Functions for Firebase.
Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers.
Hope it helps.