Wednesday, 3 July 2019

Firestore error when adding a value to a collection with API 16 and 17

I am trying to add/get a value to a collection in firebase. It is working fine with a mobile with Android 6.0.0 and another with Android 8.1.0 but when I am trying to do de same with an Android 4.2.0 it fails with this exception message:

com.google.firebase.firestore.FirebaseFirestoreException: Failed to get document because the client is offline.

Here is the peace of code that I am using:

private val userCollections = firestore.collection(USERS)

private fun getCollectionDocument(collectionId: String, id: String) = Single.create<FavoriteData> { single ->
    userCollections.document(FirebaseObject.userId).collection(collectionId)
            .document(id)
            .get()
            .addOnCanceledListener {
                if (!single.isDisposed) {
                    single.onError(FirebaseCancelled())
                }
            }
            .addOnFailureListener {
                if (!single.isDisposed) {
                    single.onError(it)
                }
            }
            .addOnSuccessListener {
                if (!single.isDisposed) {
                    single.onSuccess(favoriteDataMapper.map(it))
                }
            }
}

With Api 16 mobile it goes to addOnFailureListener with the message I wrote above.



from Firestore error when adding a value to a collection with API 16 and 17

No comments:

Post a Comment