mk-5 / gdx-fireapp

libGDX Firebase API
Apache License 2.0
65 stars 21 forks source link

[iOS Database] Can't read string value #13

Closed Corrob closed 5 years ago

Corrob commented 5 years ago

Describe the bug When I try to read a String from the database, I get the follow error: Result data type mismatch. Wanted type: class java.lang.String, result data type: class java.lang.String

To Reproduce Run the following

DatabaseDistribution database = GdxFIRDatabase.instance();
database.inReference("testing").setValue("some string");
database.inReference("testing").readValue(String.class, new DataCallback<String>() {
  @Override
  public void onData(String data) {
    Gdx.app.log("Testing", data);
   }

  @Override
  public void onError(Exception e) {
    Gdx.app.log("Testing", "Error...\n" + e.getLocalizedMessage() + "\n" + e.getStackTrace());
  }
});

I expect it to log "some string". Instead, I get the error: Error... Result data type mismatch. Wanted type: class java.lang.String, result data type: class java.lang.String [Ljava.lang.StackTraceElement;@6393d95

This same code works fine on Android or with Integers on iOS. I also validated that the string is properly written to the database.

I suspect there might be some issue with the if/else clauses at https://github.com/mk-5/gdx-fireapp/blob/4336099a9da7f9e8862d2e080b2316075a2f625e/gdx-fireapp-ios-moe/src/mk/gdx/firebase/ios/database/DataProcessor.java.

Platform (please check one of the following):

Smartphone (please complete the following information only if platform is Android or iOS):

I really appreciate your work to support Firebase with LibGdx!

mk-5 commented 5 years ago

Hello! and thanks for reporting ! :)

I'll look on that and let you know

mk-5 commented 5 years ago

Okay, you are right, the issue is in DataProcessor. The ios firebase api returns String instead of NSString.

I'll fix that very soon. The fix will be in version 1.9.2