Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #8615: NetInfo.isConnected for iOS
Summary: This is fixing #8615. The problem was that, on initialization, the `_connectionType` variable was still set to its default value of `RCTConnectionTypeUnknown`. The exposed API method did nothing to determine this unless a subscription had be established and then the method would simply return the last reported value. Instead, the exposed oneshot API call now actually checks the connection status through the same methods as the subscription and updates RCTNetInfo’s values before returning. In order to avoid reporting events without a subscription, a flag is set and unset on calls to start/stopObserving. - start app - observe the (in)correct reporting of the manual status - change network status to offline - press refresh - observe the manual fetch - start subscription - change network status to online - press refresh to show that the manual refresh works (only now working for current RN version) - change network status to offline - stop subscription - change network status to online - press refresh to show manual refresh does(n't) work without subscription - start subscription to show it updates to current Current Behavior: https://drive.google.com/file/d/1Ods6HORgp_vfm1mQVjGwhtH1D7issxjo/view?usp=sharing Fixed Behavior: https://drive.google.com/file/d/11H1UOF33LeMGvXEOoapU62ARDSb7qoYv/view?usp=sharing [IOS] [BUGFIX] [Libraries\Network\RCTNetInfo.m] - Fixed #8615, `iOS: NetInfo.isConnected returns always false`, by decoupling the fetch from the status of the subscription. Closes #17397 Differential Revision: D7102771 Pulled By: hramos fbshipit-source-id: ea11eb0b1a7ca641fc43da2fe172cf7b2597de4a
- Loading branch information
dbafc29
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about android? Is the NetInfo bug fixed in android as well?