I am working with interactive push notifications, when i reply to a PN, which should be updating firbase databsae. It doesn't works well because some times if the app is in background the data is not synced in real time. but when u open the app it pushes the data
if the app is in a killed state the reply is not even send to Firebase DB
Ref.child(uId).runTransactionBlock({ (currentData: FIRMutableData) -> FIRTransactionResult in
var value = currentData.value as? [String : AnyObject]
if value == nil {
return FIRTransactionResult.success(withValue: currentData)
}
let totR = value!["totalReply"] as? Int ?? 0
print(totR)
value?["totalReply"] = totR + 1
currentData.value = value
}