Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 28468

Getting list of available Wifi's on react native(android)

$
0
0

I want to get the available WiFi networks on my react-native android app. I went through a few blog posts and StackOverflow questions, but I am unable to achieve the desired functionality. react-native-android-wifi is an npm package, which is expected to achieve the functionality, but I am getting an error of PermissionsAndroid not defined when trying to execute the code for asking user's permission to enable WiFi. Below is the code,

    try {
          const granted = await PermissionsAndroid.request(
            PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
            {
              'title': 'Wifi networks',
              'message': 'We need your permission in order to find wifi networks'
            }
          )
          if (granted === PermissionsAndroid.RESULTS.GRANTED) {
            console.log("Thank you for your permission! :)");
          } else {
            console.log("You will not able to retrieve wifi available networks list");
          }
        } catch (err) {
          console.warn(err)
        }

Can someone please help me out here and please tell me how can I reach my desired outcome.


Viewing all articles
Browse latest Browse all 28468

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>