0

I'm making simple mobile app using react-native. it's server check some http resource every minute. If the changes exist, it send push notifications to user.

In this situation, can I use Google Cloud Functions (Cloud Functions for Firebase) as a server?

I searched some cloud function example but they usually are kinds of event listener, http request or background change event.

Can I use cloud functions for those cron jobs?

exports.checkNewData = function(url){

    var latestData = db.get.latestData;

    request.get(url, function(res, body){ 
       if(body != latestData) sendPush('There is a new data')... 
    })    
}

If can, How do I execute that function every minute?

Is it okay to just wrapping setInterval the inside of function?

Let Me Tink About It
  • 11,866
  • 13
  • 72
  • 169
JuntaeKim
  • 5,364
  • 15
  • 54
  • 97
  • 1
    There is no cron-like functionality in Cloud Functions at the moment. See http://stackoverflow.com/questions/42790735/cloud-functions-for-firebase-trigger-on-time/42796988#42796988. I also recommend reading this blog post, which is about this exact topic: https://firebase.googleblog.com/2017/03/how-to-schedule-cron-jobs-with-cloud.html – Frank van Puffelen Mar 25 '17 at 04:45
  • 1
    There's also a cloud function sample that does something similar: https://github.com/firebase/functions-samples/tree/master/delete-unused-accounts-cron it does use an external cron service though. – Salakar Mar 25 '17 at 16:00

0 Answers0