0

We were working on Data connectivity application in React Native. Here we want to switch internet connection from wifi to mobile data. But before switching we wanted to check if user is having Data connectivity enabled with internet access. Is there any way to detect the same in React Native or in Android or Swift natively.

Any help or suggestions is appreciated.

  • duplicate of this question https://stackoverflow.com/questions/57296756/how-to-check-internet-connection-in-react-native-application-for-both-ios-and-an – shubham jha Aug 28 '22 at 11:11
  • @shubhamjha My Query is different, I want check the connectivity of data network while my current connectivity is wifi network. – Mahesh Shinde Aug 28 '22 at 11:17
  • You just try and make a connection to your server. If it works you have connectivity. It it fails you don't. – Paulw11 Aug 28 '22 at 11:55
  • @Paulw11 I have to turn off the wifi if user has mobile data connectivity and if not I have to stay on same wifi. Is it possible if I am connected to wifi but would like to check the mobile data connectivity before turning it off. – Mahesh Shinde Aug 28 '22 at 15:15
  • yes you can do this with expo netinfo package https://docs.expo.dev/versions/latest/sdk/netinfo/ – mirsahib Aug 28 '22 at 15:56
  • Please provide enough code so others can better understand or reproduce the problem. – Community Aug 29 '22 at 03:45

0 Answers0