react-native/Libraries
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
..
ART Update license headers for MIT license 2018-02-16 18:31:53 -08:00
ActionSheetIOS Update license headers for MIT license 2018-02-16 18:31:53 -08:00
Alert Fix ESLint warnings using 'yarn lint --fix' 2018-02-22 07:23:17 -08:00
Animated RN: Remove Animated -> ScrollView -> Animated Cycle 2018-02-20 20:35:08 -08:00
AppState Fix ESLint warnings using 'yarn lint --fix' 2018-02-22 07:23:17 -08:00
BatchedBridge Update license headers for MIT license 2018-02-16 18:31:53 -08:00
Blob Update license headers for MIT license 2018-02-16 18:31:53 -08:00
BugReporting Update license headers for MIT license 2018-02-16 18:31:53 -08:00
CameraRoll @allow-large-files Upgrade xplat/js to Flow v0.66 2018-02-16 20:24:57 -08:00
Components onPress animation with magnification 2018-02-27 13:10:02 -08:00
Core RN: Remove React Stack Systrace Logic 2018-02-19 22:32:36 -08:00
EventEmitter Update license headers for MIT license 2018-02-16 18:31:53 -08:00
Experimental @allow-large-files Upgrade xplat/js to Flow v0.66 2018-02-16 20:24:57 -08:00
Geolocation Fix ESLint warnings using 'yarn lint --fix' 2018-02-22 07:23:17 -08:00
Image Update license headers for MIT license 2018-02-16 18:31:53 -08:00
Inspector Update license headers for MIT license 2018-02-16 18:31:53 -08:00
Interaction Update license headers for MIT license 2018-02-16 18:31:53 -08:00
JSInspector Update license headers for MIT license 2018-02-16 18:31:53 -08:00
LayoutAnimation Update license headers for MIT license 2018-02-16 18:31:53 -08:00
Linking Fix ESLint warnings using 'yarn lint --fix' 2018-02-22 07:23:17 -08:00
LinkingIOS Update license headers for MIT license 2018-02-16 18:31:53 -08:00
Lists @allow-large-files Upgrade xplat/js to Flow v0.66 2018-02-16 20:24:57 -08:00
Modal Fix ESLint warnings using 'yarn lint --fix' 2018-02-22 07:23:17 -08:00
NativeAnimation Update license headers for MIT license 2018-02-16 18:31:53 -08:00
Network Fix #8615: NetInfo.isConnected for iOS 2018-02-27 14:16:20 -08:00
Performance RN: Remove React Stack Systrace Logic 2018-02-19 22:32:36 -08:00
PermissionsAndroid Fix ESLint warnings using 'yarn lint --fix' 2018-02-22 07:23:17 -08:00
PushNotificationIOS Fix ESLint warnings using 'yarn lint --fix' 2018-02-22 07:23:17 -08:00
RCTTest Update license headers for MIT license 2018-02-16 18:31:53 -08:00
ReactNative update FabricUIManager to call the right JS object 2018-02-23 17:04:40 -08:00
Renderer Clean up unused modules 2018-02-26 20:03:27 -08:00
Sample Standardize project indentation settings on 2 spaces 2017-07-31 05:20:03 -07:00
Settings Update license headers for MIT license 2018-02-16 18:31:53 -08:00
Share Update license headers for MIT license 2018-02-16 18:31:53 -08:00
Storage Fix ESLint warnings using 'yarn lint --fix' 2018-02-22 07:23:17 -08:00
StyleSheet Update license headers for MIT license 2018-02-16 18:31:53 -08:00
SurfaceBackedComponent Update license headers for MIT license 2018-02-16 18:31:53 -08:00
SurfaceHostingComponent Update license headers for MIT license 2018-02-16 18:31:53 -08:00
Text Support Input Accessory View (iOS Only) [1/N] 2018-02-27 11:09:30 -08:00
Types RN: Flow Type for `PressEvent` 2018-02-25 23:27:00 -08:00
Utilities Update license headers for MIT license 2018-02-16 18:31:53 -08:00
Vibration Fix ESLint warnings using 'yarn lint --fix' 2018-02-22 07:23:17 -08:00
WebSocket Remove Platform check from WebSocket module 2018-02-23 11:17:27 -08:00
Wrapper Yoga float vs. CoreGraphics float in RCTWrapper 2018-01-08 14:48:55 -08:00
fishhook Merge fishhook.xcodeproj in RCTWebSocket 2017-08-09 07:48:09 -07:00
polyfills Update license headers for MIT license 2018-02-16 18:31:53 -08:00
react-native Update license headers for MIT license 2018-02-16 18:31:53 -08:00
vendor Update license headers for MIT license 2018-02-16 18:31:53 -08:00
.npmignore npmignore: ignore tests and fixtures 2018-02-27 08:42:14 -08:00
Promise.js Update license headers for MIT license 2018-02-16 18:31:53 -08:00
UTFSequence.js Update license headers for MIT license 2018-02-16 18:31:53 -08:00
promiseRejectionIsError.js Update license headers for MIT license 2018-02-16 18:31:53 -08:00