2

I am looking at ways to detect when a specific connection is available. For example when the user gets home and the network is picked up they are able to be given a notification as to whether they would like to join the network. At the minute I am trying to do this in React so would be interested in what options I have available native or not.

I have seen this previous question which is along very similar lines but I am not currently looking specifically for android. Android WIFI How To Detect When Specific WIFI Connection is Available

Community
  • 1
  • 1
Lilp
  • 961
  • 1
  • 11
  • 31

1 Answers1

2

You should use NetInfo for this. You can find specific documentation here.

Here is a quick example of what you are trying to do:

NetInfo.addEventListener(
   'change',
   function(reach) {
       if(reach.toLowerCase() === 'wifi' ) {
           console.log('You are on wifi!');
       }
   }
);
Emilio Rodriguez
  • 5,709
  • 4
  • 27
  • 32