Firebase database save data after approval

I am using firebase database in iOS app! I write fast. I am using Submit button to write data (like text fields and label values) to my firebase database. Is there a way to accept or reject data in my database? I mean, if the user adds something to the textbox and clicks send (which means adding it to my database), I want to accept or reject it in 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.")
        }

    }

      

+3


source to share


2 answers


If I understood you correctly, then the First way :

1) Add an extra field like isAccepted

2) Add new value to your node, but only show if isAccepted == true

.

3) If false

shown UIView

for approval.

Second way:



1) You have to create an extra node named like Suggested actions

2) Let the user add to this node

3) Check with your user for this node and accept / reject.

4) If accepted - add to the final node

Hope it helps

0


source


Another way to enable standalone firebase database capability. This will improve processing and you won't need to deal with it. This will be achieved with just one line of code.



0


source







All Articles