blackdeve / react-native-wifi

A react-native implementation for viewing and connecting to Wifi networks on Android and iOS devices.
76 stars 89 forks source link

Android: crash/native error on connect if wifi disabled #7

Open pstanton opened 6 years ago

pstanton commented 6 years ago

it would be nice to include an "enable wifi" function, or at least an "is wifi enabled" function...

However, when executing connectToProtectedSSID with wifi disabled, I get the following exception:

"Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference"

connectTo RNWifiModule.java:261 connectToProtectedSSID RNWifiModule.java:186

pstanton commented 6 years ago

1 possibly related

pstanton commented 6 years ago

gotta love undocumented features:

        try {
            WifiManager.isEnabled(function(enabled) {
                console.log("WiFi", "isEnabled", enabled);
            });
        } catch (e) {
            console.log("WiFi", "can't isEnabled", e);
        }

This is not available for IOS however.