나는 많은 것을 시도해 왔으며 인터넷에서 많은 것을 검색해 왔지만 코드가 어떻게 설정 되었기 때문에 나를 돕는 해결책을 찾을 수 없습니다.firebase에서 게시물을 삭제하는 방법은 무엇입니까? Swift
내가 게시물을 삭제하려고 한 방법 중 하나를하지만 난 정말 내 게시물 중포 기지에 의해 생성 된 자동 ID에 업로드되어 있기 때문에이 작업을 수행하는 방법을 모르는 내가
Database.database().reference.child("posts").child("HERE IS THE AUTO ID").removeValue
여기에 작성하는 것을 잘 모릅니다
어떻게받을 수 있습니까? 제발이 문제에 대해 지금 당황했습니다. 자위를 얻는 방법에 대한 단서가 없습니다.
이 내가
if (self.imageFileName != "") {
if choosenCountryLabel.text == "Albania" {
// image has finshed the uploading, Saving Post!!!
if let uid = Auth.auth().currentUser?.uid {
Database.database().reference().child("users").child(uid).observeSingleEvent(of: .value, with: { (snapshot) in
if let userDictionary = snapshot.value as? [String: AnyObject] {
for user in userDictionary{
if let username = user.value as? String {
if let streetAdress = self.locationAdressTextField.text {
if let title = self.titleTextField.text {
if let content = self.contentTextView.text {
let postObject: Dictionary<String, Any> = [
"uid" : uid,
"title" : title,
"content" : content,
"username" : username,
"time" : self.timeStamps,
"timeorder" : self.secondTimeStamps,
"image" : self.imageFileName,
"adress" : streetAdress,
"postAutoID" : self.postAutoID
]
let postID = Database.database().reference().child("posts").childByAutoId()
let postID2 = Database.database().reference().child("AlbaniaPosts").childByAutoId()
let postID3 = Database.database().reference().child(uid).childByAutoId()
postID.setValue(postObject)
postID2.setValue(postObject)
postID3.setValue(postObject)
let postAutoID = postID.key
let postAutoID2 = postID2.key
let postAutoID3 = postID3.key
print(postAutoID)
print(postAutoID2)
print(postAutoID3)
let alertPosting = UIAlertController(title: "Successfull upload", message: "Your acty was successfully uploaded.", preferredStyle: .alert)
alertPosting.addAction(UIAlertAction(title: "OK", style: .default, handler: { (action) in
let vc = self.storyboard?.instantiateViewController(withIdentifier: "AlbaniaVC")
self.present(vc!, animated: true, completion: nil)
}))
self.present(alertPosting, animated: true, completion: nil)
print("Posted Succesfully to Firebase, Saving Post!!!")
}
}
}
}
}
}
})
}
}
}else{
let alertNotPosting = UIAlertController(title: "Seems like you got connection problems", message: "Your image has not been uploaded. Please Wait 10 seconds and try again.", preferredStyle: .alert)
alertNotPosting.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
self.present(alertNotPosting, animated: true, completion: nil)
}
빠른 질문 : 사용자가 어떤 게시물을 어떻게 알 수 있습니까? 삭제 중입니까? –
@ RosárioPereiraFernandes 오른쪽에서 왼쪽으로 스 와이프하여 특정 게시물을 삭제할 수 있습니다. – Jiyar
"스 와이프를 삭제 하시겠습니까?"라는 코드를 게시 할 수 있습니까? 거기에서 당신을 도우려는 것이 더 쉬울 수도 있습니다. –