【问题标题】:(ios,swift) firebase realtime database can't write when everything is connected(ios,swift)当一切都连接时,firebase 实时数据库无法写入
【发布时间】:2019-07-24 10:16:01
【问题描述】:

我是 firebase 新手,正在尝试将一些数据写入 firebase。 我的问题如下: 已安装 pod 'Firebase/Core' pod 'Firebase/数据库' coacopods 和 Xcode 中的 import Firebase,也改变了实时数据库规则 “read” 和 “write” 都是 true,一切都连接到 google firebase,但仍然无法在实时数据库中写入数据?有人和我有同样的问题吗?谁能帮我修复它?

代码 第一部分(AppDelegate.swift): 导入 UIKit 导入 Firebase

@UIApplicationMain 类 AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.

    **FirebaseApp.configure()**

    return true
}

第二部分(ViewController.swift): 导入 UIKit 导入 Firebase 导入 FirebaseDatabase

类视图控制器:UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()

    **let ref = Database.database().reference()**

    **ref.child("someid/name").setValue("mike")**
}

} Xcode 或 firebase 中没有显示任何错误消息。

【问题讨论】:

  • 你能运行一个 HTTP 流量嗅探器,看看是否有传出请求吗?

标签: ios swift database firebase firebase-realtime-database


【解决方案1】:

我建议您通过再次从控制台下载来更新您的 GoogleService-Info.plist。这解决了我的问题。

【讨论】:

  • 你认为它是如何解决问题的?
  • 我猜我的文件有问题。我检查了 ref,它是正确的,但是 ref.child("someid/name").setValue("mike") 行什么也没做,向该行添加了完成但它没有进入阻止.更改文件后它以某种方式工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-14
  • 2021-08-24
相关资源
最近更新 更多