Welche Berechtigungen sind erforderlich, um das Wi-Fi-SSID in React Native zu holen?Android

Forum für diejenigen, die für Android programmieren
Anonymous
 Welche Berechtigungen sind erforderlich, um das Wi-Fi-SSID in React Native zu holen?

Post by Anonymous »

Ich habe alle möglichen Berechtigungen in React Native ausprobiert, aber ich kann das Wi-Fi-SSID immer noch nicht abrufen. Ich habe alles getestet, was ich kann, und die Erlaubnis zur Standort wird definitiv erteilt. Ich konnte das Wi-Fi-SSID schon einmal bekommen, aber jetzt, egal was ich tue, gibt es immer unbekannte SSID zurück. < /P>
< /code>
`< /p>
useEffect(() => {
console.log('Location permission status:', locationPermission);
if (locationPermission) {
fetchWifiSSID();
checkWifiConnection();
} else {
console.log('Wi-Fi SSID cannot be fetched because location permission is not granted.');
}
}, [locationPermission]);

const checkWifiConnection = async () => {
const ipAddress = await NetworkInfo.getIPV4Address();
console.log('Device IP address:', ipAddress);

if (!ipAddress) {
console.log('Device is not connected to Wi-Fi or no network connection.');
} else {
console.log('Device is connected to Wi-Fi.');
}
};

const fetchWifiSSID = async () => {
try {
console.log('Attempting to fetch Wi-Fi SSID...');
const ssid = await WifiManager.getCurrentWifiSSID();
console.log('Fetched SSID:', ssid);

if (ssid) {
setWifiSSID(ssid);
} else {
console.log('SSID could not be fetched. No Wi-Fi connection or permissions are missing.');
}
} catch (error) {
console.error('Error occurred while fetching Wi-Fi SSID:', error);
}
};`
` LOG Location permission status: true
LOG Attempting to fetch Wi-Fi SSID...
ERROR Error occurred while fetching Wi-Fi SSID: Error: Location service is turned off
LOG Device IP address: 192.163.4.6
LOG Device is connected to Wi-Fi`
< /code>
Ich habe sowohl die React-Native-Network-Info- als auch die React-native-Wifi-Re-Born-Pakete ausprobiert, aber es funktioniert immer noch nicht. Ich werde unbekannt SSID, obwohl ich alles getestet habe und die erforderlichen Standortberechtigungen habe.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post