JuanSeBestia/react-native-wifi-reborn

ERROR [TypeError: _reactNativeWifiReborn.default.reScanAndLoadWifiList is not a function (it is undefined)]

cback97 opened this issue · 3 comments

Literally can't get anything in this package to run, even in a bare project outside of expo. Why?

"dependencies": {
    "@expo/vector-icons": "^14.0.2",
    "@react-navigation/native": "^6.0.2",
    "expo": "~51.0.24",
    "expo-font": "~12.0.9",
    "expo-linking": "~6.3.1",
    "expo-router": "~3.5.20",
    "expo-splash-screen": "~0.27.5",
    "expo-status-bar": "~1.12.1",
    "expo-system-ui": "~3.0.7",
    "expo-web-browser": "~13.0.3",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "0.74.3",
    "react-native-ble-plx": "^3.2.1",
    "react-native-reanimated": "~3.10.1",
    "react-native-safe-area-context": "4.10.5",
    "react-native-screens": "3.31.1",
    "react-native-web": "~0.19.10",
    "react-native-wifi-reborn": "^4.12.1"
  },

app.json ios config

    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.cbgreen.WayFinder",
      "infoPlist": {
        "CADisableMinimumFrameDurationOnPhone": true,
        "NSAppTransportSecurity": {
          "NSAllowsArbitraryLoads": false,
          "NSAllowsLocalNetworking": true
        },
        "NSBluetoothAlwaysUsageDescription": "Allow WayFinder to connect to bluetooth devices",
        "NSLocationWhenInUseUsageDescription": "We need access to your location to gather WiFi information.",
        "NSLocationAlwaysUsageDescription": "We need access to your location to gather WiFi information even when the app is in the background.",
        "NSLocationAlwaysAndWhenInUseUsageDescription": "We need access to your location to gather WiFi information.",
        "com.apple.developer.networking.HotspotConfiguration": true,
        "UIUserInterfaceStyle": "Automatic",
        "UIStatusBarStyle": "UIStatusBarStyleDefault",
        "UIRequiresFullScreen": false,
        "UISupportedInterfaceOrientations": [
          "UIInterfaceOrientationPortrait",
          "UIInterfaceOrientationPortraitUpsideDown"
        ],
        "UISupportedInterfaceOrientations~ipad": [
          "UIInterfaceOrientationPortrait",
          "UIInterfaceOrientationPortraitUpsideDown",
          "UIInterfaceOrientationLandscapeLeft",
          "UIInterfaceOrientationLandscapeRight"
        ],
        "UIViewControllerBasedStatusBarAppearance": false
      }
    },

app.json plugins

"plugins": [
      "expo-router",
      "react-native-wifi-reborn",
      "react-native-ble-plx"
    ],

In code use

  const scanWifi = async () => {
    try {
      const networks: WifiEntry[] = await WifiManager.reScanAndLoadWifiList();
      setWifiNodes(networks);
    } catch (error) {
      console.error(error);
    }
  };

Facing same issue

useEffect(() => {
const fetchWifi = async () => {
setIsLoading(true);
const WiFiName = await getConnectedWiFiName();
console.log(
'WiFiName====WiFiNameWiFiNameWiFiNameWiFiName======',
WiFiName,
);
try {
const wifiArray = await WifiManager.loadWifiList();
const newWiFiArray = removeDuplicates(wifiArray);
if (Array.isArray(newWiFiArray) && newWiFiArray.length !== 0) {
setWifiList(newWiFiArray);
}
setIsLoading(false);
} catch (error) {
console.log('error==========', error);
}
};
fetchWifi();
}, []);

"dependencies": {
"react": "18.2.0",
"react-native": "0.74.3",
"react-native-wifi-reborn": "^4.12.1",
},

@cback97 Looks like you're trying to run this on an iPhone, loadWifiList and reScanAndLoadWifiList are Android only functions, because iOS do not support scanning for Wi-Fi. Similar issue #394.

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community attention? This issue may be closed if no further activity occurs.