Skip to content Skip to sidebar Skip to footer

Firebase Server Sdk - How Do I Schedule A Task?

I was told to schedule tasks in the cloud to do tasks to my Realtime Database in Firebase I need to use the Server SDK. Let's say I'm saving data to the Firebase database using thi

Solution 1:

If you have a 3rd party server (that uses the Firebase SDK, server SDK), you can poll all saved data and will call either a TImerService or a CRON JOB to have it persist the list to the Firebase Realtime Database.

It will depend on your server implementation, but a queueing implementation indicated above would work in your scenario.

An example of CRON job to call a webservice (in your case, the one that will persist all queued items to Firebase) can be found on this StackOverflow page. For TimerService, you can refer to its documentation

Happy coding!

Solution 2:

Create a broadcast reciever and define it in your manifest. Override onRecieve and put your firebase code there. Then define the receiver in your manifest. Create a pendingIntent using the Receiver and set it in a AlarmManager, by using the setExact() method and pass in the pendingIntent.

Solution 3:

Currently there is no way for you to run your code on Firebase's server. There are 2 options for you 2 solve this:

  1. You could use Firebase Queue and run your code in Node.js
  2. You could use a different library such as Microsoft Azure (I still haven't tried this yet, I'm not sure if it provides Job Scheduling for Android)

However, Firebase is working on something called Firebase Trigger, which will solve our problem, however it is still not released with no confirmed release date.

Post a Comment for "Firebase Server Sdk - How Do I Schedule A Task?"