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);
})
Log 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" }
Log 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" }
import NetInfo from "@react-native-community/netinfo";
import { PermissionsAndroid } from 'react-native';
async function requestLocationPermission() {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log("Location permission granted");
} else {
console.log("Location permission denied");
}
} catch (err) {
console.warn(err);
}
}
requestLocationPermission().then(() => {
NetInfo.fetch("wifi").then((state) => {
console.log("SSID:", state.details.ssid);
console.log("BSSID:", state.details.bssid);
});
});