Firebase Database saving data after approvement

Viewed 126

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!

My button action:

@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.")
        }

    }
2 Answers
Related