I only recently started learning Kotlin and using Firebase. I just had a few questions about the offline sync functionality. For context, the app I made, submits forms of information (mostly just booleans but I want to have images in the future too). I've got the offline part setup and have played around with it. I was just wondering:
- What happens if I close the app while there are still offline forms in the sync "queue".
- Are there limitations to this sync queue? e.g. size, amount of forms. Especially on the free plan for Firebase Realtime Database.
Here is the code I have written to do the offline syncing (used in a "private fun" for a setOnClickListener:
val ref = FirebaseDatabase.getInstance().getReference("Inspections")
ref.keepSynced(true)
val fdbTubingId = ref.push().key
val inspec = Inspection(ds, fdbTubingId.toString(), uniqueID, fac, ss, tid, fType,
Q1Aa, Q1Bb, Q1Cc, Q1CComment,
Q2Aa, Q2Bb, Q2Cc, Q2Dd, Q2CComment,
Q3Aa, Q3Bb, Q3CAa, Q3CBb, Q3CCc, Q3CComment,
Q4Aa, Q4Bb, Q4Cc, Q4Dd, Q4CComment,
Q5Aa, Q5Bb, Q5CComment,
Q6Aa, Q6CComment)
if (fdbTubingId != null) {
ref.child(fdbTubingId).setValue(inspec).addOnCompleteListener {
Toast.makeText(applicationContext, "Inspection saved successfully", Toast.LENGTH_LONG).show()
}
}
Thanks.