我被告知要安排任务在云中,以便对Firebase中的实时数据库执行任务,我需要使用Server SDK.
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.
假设我正在使用以下代码将数据保存到Firebase数据库中:
Let's say I'm saving data to the Firebase database using this code:
DatabaseReference usersRef = ref.child("users"); Map<String, User> users = new HashMap<String, User>(); users.put("alanisawesome", new User("June 23, 1912", "Alan Turing")); users.put("gracehop", new User("December 9, 1906", "Grace Hopper")); usersRef.setValue(users);但是我想作为明天的任务上传.我的意思是,这将节省TOMORROW,而不是立即运行此代码.
But I want to upload this as a task for tomorrow. What I mean is, this will save TOMORROW instead of the instant this code gets run.
我准备好日历:
Calendar cal = Calendar.getInstance(); cal.add(DAY_OF_MONTH,1); //This could be wrong, but I'm just telling you I have a Calendar ready, so ignore any errors in this code那么,如何使用Firebase Server SDK保存任务?这些文档没有提供明确的答案,因为我唯一能看到的就是像实时数据库一样保存数据.
So, how can I save a task using the Firebase Server SDK? The docs don't provide a clear answer for this since the only thing I can see is saving data just like the Realtime Database.
推荐答案当前,您无法否在Firebase的服务器上运行代码.有2种解决方案供您2解决此问题:
Currently there is no way for you to run your code on Firebase's server. There are 2 options for you 2 solve this:
但是,Firebase正在开发名为 Firebase Trigger 的东西,它可以解决我们的问题,但是仍然没有确定发布日期的情况下仍未发布.
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.
更多推荐
Firebase Server SDK
发布评论