Firebase数据库在批准后保存数据 [英] Firebase Database saving data after approvement
问题描述
我正在iOS应用上使用firebase数据库!我写得很快.我正在使用发送"按钮在firebaseDatabase上写入数据(例如textField和label值).有什么方法可以接受或拒绝数据库中的数据?我的意思是,如果用户将某些内容添加到文本字段并按send(将其添加到我的数据库中),那么我想接受或拒绝它,然后再添加到我的数据库中!
I'm using firebase database on an iOS app! I'm writing in swift. I'm using a 'Send' button to write data (ex. textField and label values) on my firebaseDatabase. Is there any way to accept or decline data on my database? What I mean is if a user add something to textfield and press send (which means adding it to my database), I want to accept or decline it to my database, before adding it there!
我的按钮操作:
@IBAction func saveBtn(_ sender: Any) {
//Saving item to database
if commentTextField.text != "" && placeLabel.text != "Location"
{
let place = placeLabel.text
let key = dbRef!.child("placeLabel").childByAutoId().key
dbRef!.child(place!+"/placeLabel").child(key).setValue(place)
dbRef!.child(place!+"/comment").child(key).setValue(commentTextField.text)
dbRef!.child(place!+"/rating").child(key).setValue(ratingControl.rating)
commentTextField.text = ""
//alert
createAlert(title: "Thank you!", message: "Review submitted.")
self.navigationController?.popViewController(animated: true)
}else{
//alert
createAlert(title: "Why don't write a review?", message: "Please write a review.")
}
}
推荐答案
启用firebase数据库的脱机功能的另一种方法.它会增强处理能力,而您不需要处理它.这仅需一行代码即可实现.
Another way to enable offline capability of firebase database. It will enhance the processing and you don't need to handle this.This will achieve with one line of code only.
这篇关于Firebase数据库在批准后保存数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!