Firebase Server SDK

编程入门 行业动态 更新时间:2024-10-27 12:28:04
本文介绍了Firebase Server SDK-如何安排任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我被告知要安排任务在云中,以便对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队列,然后在Node.js中运行代码
  • 您可以使用其他库,例如 Microsoft Azure (我还没有尝试过,我不确定它是否提供Android的Job Scheduling )
  • You could use Firebase Queue and run your code in Node.js
  • 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)
  • 但是,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

    本文发布于:2023-08-01 16:34:47,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1269894.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:Firebase   Server   SDK

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!