Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delay Google Cloud Function

I have a swift iPhone application paired with Google Firebase. Within the application the user will complete an action (press a button). At this point, I would like to schedule a Google Firebase Function to run 45 minutes after the user action. However, I would like this function to be able to be cancelled when another action (press a button) is completed within the iPhone application. I could do this within swift with a timer but that wouldn't work if the user closes the application.

I am not opposed to using a third party scheduler or something of the sorts. Any suggestion welcome.

I have looked at the possible duplicate questions and answers (Cloud Functions for Firebase trigger on time?) However, most of the links in that answer are deprecated and out of date. Also, that is referring to scheduling something repeatedly. For example, every hour, once a day, etc... I am looking to schedule the job 45 minutes after trigger (user action) with the ability to cancel the job within that 45 minute window.

like image 831
goalguy Avatar asked Apr 27 '26 09:04

goalguy


1 Answers

Would a delayed Cloud Task work for you?

You can create a Cloud Task that is delayed and calls your function through an HTTP trigger. The task can be then cancelled if your user performs the second action you desribe. There is a number of dedicated client libraries for Cloud Tasks, as well as a REST API.

like image 126
Voy Avatar answered Apr 30 '26 05:04

Voy