react-native-network-info icon indicating copy to clipboard operation
react-native-network-info copied to clipboard

Can't get wifi info on Android 13

Open zhenguet opened this issue 1 year ago • 1 comments

As title, I cant get Wifi info on android 13, it run nomally on android 12

    import {NetworkInfo} from 'react-native-network-info';

    NetworkInfo.getSSID().then(ssid => {
      setWifiSSID(ssid || '');

      console.log(ssid); 
      // 12: AndroidWifi
      // 13: <unknown ssid>
    });

@react-native-community/netinfo has the same issue. Has anyone to know the ways to fix it?

    import NetInfo from '@react-native-community/netinfo';

    NetInfo.fetch('wifi').then(state => {
      setWifiType(state.type);

      console.log(state);

    /**
    * Android 12
    */

    // {
    //   "details": {
    //     "bssid": "00:13:10:85:fe:01",
    //     "frequency": 2447,
    //     "ipAddress": "****",
    //     "isConnectionExpensive": false,
    //     "linkSpeed": 1,
    //     "rxLinkSpeed": 2,
    //     "ssid": "AndroidWifi",
    //     "strength": 99,
    //     "subnet": "255.255.255.0",
    //     "txLinkSpeed": 1
    //   },
    //   "isConnected": true,
    //   "isInternetReachable": true,
    //   "isWifiEnabled": true,
    //   "type": "wifi"
    // }

    /**
    * Android 13
    */

    // {
    //   "details": {
    //     "bssid": "02:00:00:00:00:00",
    //     "frequency": 5300,
    //     "ipAddress": "*****",
    //     "isConnectionExpensive": false,
    //     "linkSpeed": 300,
    //     "rxLinkSpeed": 300,
    //     "strength": 99,
    //     "subnet": "255.255.255.0",
    //     "txLinkSpeed": 300
    //   },
    //   "isConnected": true,
    //   "isInternetReachable": true,
    //   "isWifiEnabled": true,
    //   "type": "wifi"
    // }

    });

zhenguet avatar Mar 06 '23 09:03 zhenguet

Experience the same. I think it might be connected with new permissions on Android 13: https://developer.android.com/about/versions/13/behavior-changes-13

labteam avatar Mar 20 '23 21:03 labteam