GitLiveApp/firebase-kotlin-sdk

iOS RTDB inconsistencies

Opened this issue · 0 comments

Hey

I just want to let you know about two bugs(?) I have found in this SDK.

  1. When writing a boolean from Android to RTDB, it comes out as expected ("true" or "false")
    But when writing it from iOS is comes out as Long in the database (1 or 0).

It seems like some devices manages to parse this correctly, while others do not, hence why I'm getting alot of this crash:

Fatal Exception: P3.c: Failed to convert value of type java.lang.Long to boolean
       at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.convertBoolean(CustomClassMapper.java:417)
       at 

 ...
  1. When reading an empty node in RTDB on iOS, the database snapshot value comes out as "<n.ull>" (without the dot). So when trying to parse this into an object using any Serializer it fails, and I get the default value of that object instead.

My workaround is currently to do this :

databaseRef.valueEvents.collect { snapshot ->
    val valueString = snapshot.value.toString()
    if(snapshot.value != null && valueString != "<null>") {
   ...

Android works as expected regarding this.

I am surprised no one else has had this issue, atleast I have not managed to find an issue here.

Kind regards!