react-native/Libraries/Network
Adam Burdette dbafc29e60 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 https://github.com/facebook/react-native/pull/17397

Differential Revision: D7102771

Pulled By: hramos

fbshipit-source-id: ea11eb0b1a7ca641fc43da2fe172cf7b2597de4a
2018-02-27 14:16:20 -08:00
..
RCTNetwork.xcodeproj Standardize project indentation settings on 2 spaces 2017-07-31 05:20:03 -07:00
__tests__ Update license headers for MIT license 2018-02-16 18:31:53 -08:00
FormData.js Update license headers for MIT license 2018-02-16 18:31:53 -08:00
NetInfo.js Fix ESLint warnings using 'yarn lint --fix' 2018-02-22 07:23:17 -08:00
RCTDataRequestHandler.h Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTDataRequestHandler.m Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTFileRequestHandler.h Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTFileRequestHandler.m Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTHTTPRequestHandler.h Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTHTTPRequestHandler.mm Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTNetInfo.h Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTNetInfo.m Fix #8615: NetInfo.isConnected for iOS 2018-02-27 14:16:20 -08:00
RCTNetworkTask.h Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTNetworkTask.m Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTNetworking.android.js Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTNetworking.h Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTNetworking.ios.js Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTNetworking.mm Update license headers for MIT license 2018-02-16 18:31:53 -08:00
XHRInterceptor.js Update license headers for MIT license 2018-02-16 18:31:53 -08:00
XMLHttpRequest.js Update license headers for MIT license 2018-02-16 18:31:53 -08:00
convertRequestBody.js Update license headers for MIT license 2018-02-16 18:31:53 -08:00
fetch.js Update license headers for MIT license 2018-02-16 18:31:53 -08:00