var ref = Database.database().reference().child("Essages")
var childRef = Database.database().reference().child("Essages").childByAutoId()
@IBAction func sendBtn(_ sender: Any) {
posting()
}
func posting(){
let values = ["message" : captionTextView.text] as [String : Any]
childRef.updateChildValues(values) { (error, ref) in
if error != nil {
print("error")
}else {
let = Timer.scheduledTimer(timeInterval: 90000, target: self, selector: #selector(self.onTick), userInfo: nil, repeats: false)
}
}
}
func onTick(){
childRef.removeValue()
}
If the app is open then the timer is working and it is deleting the data. But if I close the app the timer is not working and the data is not deleted. Please help me in sorting this problem. I'm trying to get feature like snapchat (deleting in 24hrs).