Firebase Database Transaction When App Is in Background iOS

firebase runTransactionBlock

Thanks to the comments seen above I was able to get this to work

....runTransactionBlock { (currentData: FIRMutableData) -> FIRTransactionResult in

var value = currentData.value as? Int

if value == nil {
value = 0
}

currentData.value = value! + 1
return FIRTransactionResult.successWithValue(currentData)

}

How to track offline transactions for Firebase iOS in Swift 4

There are no callbacks or delegates for transactions that are wiped when the user goes offline. If you want your app to handle offline situations gracefully, you should not rely on transactions in your code.

Firebase Notifications and Firebase Database features do not work at the same time in my app

Yes you can use both. It's documented pretty well on how to setup FIRDatabase: https://firebase.google.com/docs/database/ios/start

I've just built an app with both Messages and Notifications. Use CocaPods to manage and install all your dependancies.

Using transactions in Firebase

Transactions only run within the context of the database where the transaction is started. The all-or-none behavior of transactions only applies to the work that you do within the database itself, not any external properties. Your transaction handlers should be as fast as possible and not block on other work.

The usual practice for file uploads is to perform the file upload first, then after that succeeds, write to the database.



Related Topics



Leave a reply



Submit