0

Instead letting user read the status bar, is a programmatic way to detect the "no service" state?

jack2684
  • 324
  • 3
  • 15
  • Does this answer your question? [How to check internet connection in React Native application for both iOS and Android?](https://stackoverflow.com/questions/57296756/how-to-check-internet-connection-in-react-native-application-for-both-ios-and-an) – jnpdx Jan 09 '22 at 02:49
  • Apple advises against preflight checks or trying to track the connection state. The network can go away at any instant and can come back at any instant. Better to just try and handle errors. – Paulw11 Jan 09 '22 at 07:01

1 Answers1

0

you can use NetInfo package for this, at first import that :

import NetInfo from "@react-native-community/netinfo";

You can subscribe to network state changes using the addEventListener() method:

NetInfo.addEventListener(networkState => {
  console.log("Connection type - ", networkState.type);
  console.log("Is connected? - ", networkState.isConnected);
});

for more info see Link

Meisan Saba
  • 800
  • 2
  • 9
  • 25