Android 10 - type is `none` for no internet wifi connections.
See original GitHub issueEnvironment
System: OS: macOS 10.15.4 CPU: (12) x64 Intel® Core™ i7-8750H CPU @ 2.20GHz Memory: 391.18 MB / 16.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.13.0 - ~/.nvm/versions/node/v12.13.0/bin/node Yarn: 1.22.5 - /usr/local/bin/yarn npm: 6.12.0 - ~/.nvm/versions/node/v12.13.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 14.0, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0 Android SDK: API Levels: 23, 25, 26, 27, 28, 29 Build Tools: 27.0.3, 28.0.3, 29.0.2, 29.0.3 System Images: android-19 | Google APIs Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom IDEs: Android Studio: 4.0 AI-193.6911.18.40.6514223 Xcode: 12.0/12A7209 - /usr/bin/xcodebuild npmPackages: react: 16.8.6 => 16.8.6 react-native: 0.60.0 => 0.60.0 npmGlobalPackages: react-native-cli: 2.0.1 react-native-rename: 2.4.1
Platforms
Android
Versions
- Android: 10
- react-native-netinfo: 5.9.6
- react-native: 0.60.0
- react: 16.8.6
- react-native-wifi-reborn: 4.3.1 => https://github.com/JuanSeBestia/react-native-wifi-reborn
Description
Not sure if this bug belongs here. Don’t think it is a regression.
On Android 10 and Android 11, when connecting to a WIFI network that doesn’t have internet access, and the connection is performed through the OS WIFI settings, the netInfo object correctly shows the type
as wifi
, and the network details
.
When connecting to the same WIFI network, and the connection is performed through the WifiManager.connectToProtectedSSID
function from the react-native-wifi-reborn
library (and the connection succeeds), the type
in the netInfo object is always none
and the connection details
are empty.
Devices reflect being connected to the WIFI network, both on the control panel and the WIFI settings.
Not sure where this bug belongs.
- Experiencing this on several Android 10 and Android 11 devices.
- Having the same behavior with the
useNetInfo
hook, as well as when adding listeners manually.
Reproducible Demo
import React, { useEffect } from 'react';
import { useNetInfo } from '@react-native-community/netinfo';
import WifiManager from 'react-native-wifi-reborn';
const SomeComponent = () => {
const netInfo = useNetInfo();
...
useEffect(() => {
console.log(netInfo);
// netInfo object never reflects being connected to the wifi that has no internet access.
// Instead, it shows:
// {
// details: {}
// isConnected: false
// isInternetReachable: false
// isWifiEnabled: true
// type: "none"
// }
}, [netInfo]);
useEffect(() => {
WifiManager.connectToProtectedSSID('network-without-internet-access', '', false);
}, []);
...
}
Please let me know if there’s more information I can provide.
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
@pherrera91, when connecting to a new WiFi network, make sure to wait a little so all changes can be fetched correctly. You might also be getting a cached network information. If you just want to fetch the WiFi status and avoid any caching, you may call
NetInfo.fetch("wifi")
.Did a little bit more digging into the issue.
This is not true.
It seems the issue is not that
none
is returned.none
being returned is okay, because that’s the state prior to being connected to a network. The problem is that the library is not detecting the connection to the new wifi network that has no internet, and no new data is returned.I did some debugging and I ended up finding out that
onAvailable
(inside ConnectivityManager.NetworkCallback -> NetworkCallbackConnectivityReceiver.java) is never called for the network I’m connecting to.I’m still looking at it, to see if I find something else.