【发布时间】: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