Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection State return number value, not boolean #55

Closed
dzuncoi opened this issue Apr 17, 2017 · 9 comments
Closed

Connection State return number value, not boolean #55

dzuncoi opened this issue Apr 17, 2017 · 9 comments
Assignees
Labels
help: needs-triage Issue needs additional investigation/triaging. platform: ios plugin: database Firebase Realtime Database type: bug New bug report
Milestone

Comments

@dzuncoi
Copy link

dzuncoi commented Apr 17, 2017

Hi,

Currently, I'm using .info/connected to detect app connection state, as

firebase.database().ref('.info/connected').on('value', snapshot => {
    const connectionState = snapshot.val()
})

And I expect connectionState should return boolean value (true of false), as this Firebase doc.

But it doesn't, my connectionState value always return false at the first time, then return 1 if app has connection and 0 if not. Is it a correct behavior?

Ps: I'm still fine with those value, just want to confirm this behavior.

@Salakar
Copy link
Member

Salakar commented Apr 18, 2017

Seems like incorrect behaviour, can you tell me which platform this issue is on, android or ios?

@dzuncoi
Copy link
Author

dzuncoi commented Apr 18, 2017

@Salakar
I'm using iOS 10.3, react-native-firebase: 1.0.0-alpha12

@Ehesp
Copy link
Member

Ehesp commented Apr 20, 2017

@dzuncoi Speaking with @Salakar, on Android Firebase SDK it returns as true/false, however on iOS Firebase SDK it returns 1/0. The problem is it's part of a Reference, so there'd have to be some custom logic to change this (needs double checking).

@dzuncoi
Copy link
Author

dzuncoi commented Apr 20, 2017

Thanks for investigating this issue. I'm porting my app to Android as well, so I'll check and inform if there is anything should be changed.

@Salakar
Copy link
Member

Salakar commented Apr 20, 2017

Might also be an issue with the type conversion in RNFirebase also, @dzuncoi could you try see what setting/reading a boolean value on any ref returns?

We have tests for this that check all types including Booleans and it's passing, may be some weird edge case in your instance where it isn't.

The iOS SDK docs say it's bool, or at least a boleanValue:
image

@dzuncoi
Copy link
Author

dzuncoi commented Apr 21, 2017

I've tested on Android with the same codes and it return boolean values. And on Android,

my connectionState value always return false at the first time

this behavior does not happen as iOS.
It's a little bit weird. I'll test on real device soon.

@SamMatthewsIsACommonName
Copy link
Contributor

This has been the case for a while but I just deal with it by testing for either 1 or true.
Maybe it's not so elegant but it works haha

@basequatro
Copy link

Use == instead of ===

@Salakar Salakar added this to the v2 milestone Jun 7, 2017
@Ehesp Ehesp added the type: bug New bug report label Jul 10, 2017
@Salakar Salakar added plugin: database Firebase Realtime Database help: needs-triage Issue needs additional investigation/triaging. platform: ios labels Jul 24, 2017
@Salakar Salakar self-assigned this Jul 24, 2017
@Salakar
Copy link
Member

Salakar commented Aug 14, 2017

Closing this as there's not much I can do about it, native SDK's return the value like this, but android returns an actual boolean value.

@Salakar Salakar closed this as completed Aug 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help: needs-triage Issue needs additional investigation/triaging. platform: ios plugin: database Firebase Realtime Database type: bug New bug report
Projects
None yet
Development

No branches or pull requests

5 participants