【问题标题】:Firebase push() in iOSiOS 中的 Firebase push()
【发布时间】:2014-04-13 22:37:29
【问题描述】:

是否有任何等效于 iOS API 的 Firebase.push() 方法,可用于 Javascript 或 Java 的 API?

我在 iOS 的 API 参考中找不到它。

我需要的是根据时间戳(我更喜欢服务器而不是客户端时间戳)将数据推送到新的子位置,并在块中返回该引用。

【问题讨论】:

    标签: ios firebase


    【解决方案1】:

    是的!我们将它重命名为 childByAutoId 以更符合 iOS 命名约定,但它的行为与 ref.push() 相同。如果要设置数据(相当于ref.push(data)),可以[[ref childByAutoId] setValue:data]

    【讨论】:

    • 它在 iOS 上的行为似乎有所不同 - 在 Web API 上它给出一个数字作为键,但在 iOS 上是一个 UUID imgur.com/a/6y7de
    • 如何将值设置为 true?例如:如果我写:让 requestId = historyRef.childByAutoId(),然后:driverRef.child(requestId).setValue(true),我得到一个错误:“Bool”不能转换为“Any?” - 我该如何解决这个问题。
    猜你喜欢
    • 2018-09-10
    • 2020-03-14
    • 2018-04-17
    • 1970-01-01
    • 1970-01-01
    • 2016-06-27
    • 2015-11-21
    • 2019-04-11
    • 2017-08-08
    相关资源
    最近更新 更多