Tag: firebase云消息传递

将项目添加到Swift中的Firebase数组,而不先观察数组

目前,我通过观察数组,首先添加一个新的post到我的Firebase数组,附加我的新post,然后更新ref: REF_USER.child(UID).observeSingleEventOfType(.Value, withBlock: { snapshot in if !snapshot.exists() {return} if let dict = snapshot.value as? Dictionary<String, AnyObject>, let posts = dict["posts" as? [String] { posts.append(newPost) REF_USER.child(UID + "/posts").setValue(posts) } } 有没有办法跳过观察的步骤 ,并立即更新数组中的post? 假设,例如: REF_USER.child(UID + "/posts").addToArray(newPost)

iOS Swift – 获取当前本地时间和date时间戳

我试图制作一个出席应用程序,我对iOS和Firebase的date和时间非常困惑。 我使用date作为Key,这是我的Firebase数据库的结构。 –Employees –Unique_ID –Details Name: John –Attendance –dateToday Timein: 8:00 AM Timeout: 5:00 PM BreakStart: 12:00 PM BreakFinish: 1:00 PM 这是我的代码来获取我用作Key的date时间戳 override func viewDidLoad() { super.viewDidLoad() let now = NSDate() let nowTimeStamp = self.getCurrentTimeStampWOMiliseconds(dateToConvert: now) // I save this dateToday as Key in Firebase dateToday = nowTimeStamp } func getCurrentTimeStampWOMiliseconds(dateToConvert: NSDate) -> String { […]

在viewDidDisappear中删除Firebase身份validation

我正在使用Firebase的新框架,并试图在“login”和“注册”VC中分别监视用户的login状态。 问题是,如果login状态在注册视图上更改,那么“login”视图上的“身份validation状态”也会被调用。 我的问题是,如何删除身份validation状态? 我在Firebase网站上find了这个语法,但是在考虑我的代码的auth状态的时候有些困惑: FIRAuth.auth()?.addAuthStateDidChangeListener { auth, user in if let theUser = user { // User is signed in. print("LOGGED IN!!!! :::: \(theUser)") self.dismissViewControllerAnimated(true, completion: nil) } else { // No user is signed in. print("Need to login first.") } } 用于删除身份validation的代码,但不确定要传入的内容。 FIRAuth.auth()?.removeAuthStateDidChangeListener(FIRAuthStateDidChangeListenerHandle) 我说我传入一个FIRAuthStateDidChangeListenerHandle ,但我怎么获得这个,或者我重写我的authState代码不同?

在Swift中,Firebase检索自动ID下方的数据

我在从Firebase检索数据时遇到了麻烦。 我想在自动ID下读取JSON中的所有contactName数据,然后附加到UIPickerView。 这是我的JSON树(使用childByAutoId()) 这是我的Swift代码 dbRef = Database.database().reference() dbRef.child("user").child("contacts").queryOrdered(byChild: "contactName").observeSingleEvent(of: .value, with: {(snapshot) in for snap in snapshot.children { let userSnap = snap as! DataSnapshot let contactName = userSnap.value as? String self.pickOption.append("\(contactName)") } }) 但结果显示我所有的零数据…看起来像这样。 我如何解决它..?

Swift3 iOS -Firebase FIREmailPasswordAuthProvider不工作

我刚将Firebase Cocoapods从3.15.0升级到4.0.4,并将FirebaseAuth Cocoapods从3.1.1升级到4.0.0。 我正在使用电子邮件和密码来validation用户。 当用户更改他们的电子邮件时,我正在使用下面的方法,一切工作正常: FIREmailPasswordAuthProviderID.credential(withEmail: emailTextField.text!, password: passwordTextField.text!) 现在,我更新我得到错误信息 types'String'的值没有成员'凭证' 我看了文档 ,它说使用下面的方法: 问题是我得到相同的确切的错误: FIREmailAuthProviderID.credential(withEmail: emailTextField.text!, password: passwordTextField.text!) types'String'的值没有成员'凭证' 我下面的原始代码 import Firebase import FirebaseAuth let user: User? let credential = FIREmailPasswordAuthProviderID.credential(withEmail: emailTextField.text!, password: passwordTextField.text!) if let user = user{ user.reauthenticate(with: credential, completion: { (error) in if error != nil{ //…do something return } //…do something […]

Firebase检索数据 – 无法投射价值

首先,我已经检查了这些不帮我的答案: Swift JSON错误,无法将types'__NSArrayM'(0x507b58)的值转换为'NSDictionary'(0x507d74) 从Firebase获取数据 从Firebase(3.x)检索数据时,发生的错误是: Could not cast value of type '__NSArrayM' (0x10ca9fc30) to 'NSDictionary' (0x10caa0108). 用这个代码和树: 树: 检索function: func retrievePlanes() { print("Retrieve Planes") ref = FIRDatabase.database().reference(withPath: "results") ref.observe(.value, with: { snapshot in var newItems: [Planes] = [] for item in snapshot.children { let planesItem = Planes(snapshot: item as! FIRDataSnapshot) newItems.append(planesItem) } self.planes = newItems […]

如何将Firebase添加到Today Extension iOS

我需要能够在我的“今日视图扩展”中使用Firebase,但似乎无法导入Firebase模块。 我想这是因为我需要一个新的目标在我的cocoa豆荚文件,但我不知道如何做到这一点。 谢谢。

Firebase获得儿童ID快捷的ios

我的Firebase看起来像这样。 Bellow Active_Orders根据其UID (用户ID)显示不同名称的childs 。 这是我的代码,无论名字是什么,都可以得到孩子的ID。 但它似乎并没有工作。 什么是获得child ID的正确方法? 谢谢 databaseRef.child("Active_Orders").observeEventType(FIRDataEventType.Value, withBlock: { snapshot in //Get customerUID let customerUID = snapshot.value!.objectForKey("username") as! String self.setText("customerUID", value: customerUID)

iOS版的Firebase崩溃报告不会发送成功的初始化崩溃

我向我的iOS项目添加了Firebase崩溃报告(添加了pod,添加了构build阶段脚本,将json添加到项目中…)。 当我运行我的应用程序,我看到我的控制台: Firebase Crash Reporting: Successfully enabled 为了进行testing,我在我的FIRApp.configure()代码(正如这里所build议的: https ://firebase.google.com/docs/crash/ios#create_your_first_error)之后在我的代码中插入fatalError()。 我的下一个应用程序启动时不会发送崩溃报告(不会崩溃)。 我在我的xcode控制台中看不到任何东西,而在我的Web控制台中却什

无法find“Firebase”的规范

尝试时,我无法安装Firbase窗格: pod install Analyzing dependencies [!] Unable to find a specification for `Firebase` 这是我的podfile: platform :ios, '9.0' target 'login' do # Comment this line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! # Pods for login pod 'Firebase' pod 'Firebase/Auth' end