isInternetReachable is returning null on first attempt on ios
See original GitHub issueEnvironment
System: OS: macOS 12.1 CPU: (8) x64 Intel® Core™ i5-1038NG7 CPU @ 2.00GHz Memory: 1.02 GB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 17.0.1 - /usr/local/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 8.1.0 - /usr/local/bin/npm Watchman: 2021.11.08.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 Android SDK: Not Found IDEs: Android Studio: 4.0 AI-193.6911.18.40.6626763 Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild Languages: Java: Not Found npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.66.3 => 0.66.3 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Platforms
iOS
Versions
- iOS: 15.2.1
- react-native-netinfo: “^7.0.0”
- react-native: “0.66.3”
- react: “17.0.2”
Description
This is happening on real device (iPhone 11) On my app, in an on click event, i am trying to get some data from api. Before that i am checking internet connectivity. When i’m using this
import NetInfo from "@react-native-community/netinfo";
NetInfo.fetch().then(internetState => {
console.log(internetState);
if (internetState.isConnected && internetState.isInternetReachable) {
// rest of my code
}else{
// some warning
}
});
on first attempt it is returning this, with isInternetReachable is returning null. LOG {“details”: {“bssid”: null, “ipAddress”: “192.168.1.2”, “isConnectionExpensive”: false, “ssid”: null, “subnet”: “255.255.255.0”}, “isConnected”: true, “isInternetReachable”: null, “type”: “wifi”}
but if i click the button again, now isInternetReachable is returning true LOG {“details”: {“bssid”: null, “ipAddress”: “192.168.1.2”, “isConnectionExpensive”: false, “ssid”: null, “subnet”: “255.255.255.0”}, “isConnected”: true, “isInternetReachable”: true, “type”: “wifi”}
Its only happening on ios. any idea guys?
Reproducible Demo
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:17 (7 by maintainers)
Top GitHub Comments
“their” --> It is open source. There is no “they”, you are the they! All users of the library are the library developers! Welcome to the club 🤗 "waiting … " --> no need to wait! Make a PR with the fix!
Definitely going to merge the refresh PR it’s just a holiday here, been busy
If there really is a platform issue I’d welcome any PR that fixes it