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

fix(Android): Send a "none" status if the device has no active network on launch #96

Merged
merged 1 commit into from
May 18, 2019

Conversation

matt-oakes
Copy link
Collaborator

Overview

If a subscription to the network state was made on Android N+ when there was no active network, none of the callbacks would get called. Therefore, the state would be incorrectly reported as "unknown".

This PR adds a check if no active network on register and then manually calls updateAndSend() to emit the none state.

Fixes #77

Test Plan

Tested on a Pixel 2 in various states.

@cristianoccazinsp
Copy link
Contributor

Any ideas if this will also fix #64 ? My guess is that this will fix it if the app wasn't already running (i.e., a full JS VM start for the headless process), but it will report an "outdated" value if the app was already running.

I wonder if the update and send call can be exposed to the JS somehow in order to force the event to fire for such cases.

@matt-oakes
Copy link
Collaborator Author

Potentially, however, I've not been able to look into that one as there's no easily reproducible demo for it. If you can test it with this patch then that would be very useful 👍

@mikehardy
Copy link
Contributor

LGTM

@matt-oakes matt-oakes merged commit c62cd8b into master May 18, 2019
@matt-oakes matt-oakes deleted the matt-oakes/none-on-launch branch May 18, 2019 17:01
react-native-community-bot pushed a commit that referenced this pull request May 18, 2019
## [3.0.2](v3.0.1...v3.0.2) (2019-05-18)

### Bug Fixes

* **android:** Send a "none" status if the device has no active network on launch ([#96](#96)) ([c62cd8b](c62cd8b))
@react-native-community-bot
Copy link
Collaborator

🎉 This PR is included in version 3.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Offline is always repoted as "unknown" instead of "none" ?
4 participants