Firebase database transaction when app is in background iOS

旧巷老猫 提交于 2019-12-18 09:07:31

问题


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
}

回答1:


Firebase Database does not provide background syncing. Instead, it syncs data in realtime while the app is actively running. For background syncing you could use Firebase Cloud Messaging to wake the app up so that Database can then synchronize its data.



来源:https://stackoverflow.com/questions/39011182/firebase-database-transaction-when-app-is-in-background-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!