How to use the react-native-offline.checkInternetConnection function in react-native-offline

To help you get started, we’ve selected a few react-native-offline examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github developmentseed / observe / app / services / auth.js View on Github external
export async function preAuth () {
  if (!await checkInternetConnection()) {
    // return early if not connected
    return false
  }

  if (preAuthorizing) {
    try {
      // allow 5 seconds for active preauthorization to complete (after which
      // whatever is waiting will be able to continue)
      await pTimeout(waitForPreauthorization(), 5000)

      console.log('alternate preAuthorization succeeded')

      return true
    } catch (err) {
      console.log('alternative preAuthorization timed out or failed', err)
github iamrommel / offline-demo / mobile / onConnectionChange.js View on Github external
(isConnected) => {
      if (isConnected) {

        //check if there is internet connection
        checkInternetConnection().then((hasInternet) => {
          if (hasInternet)
            onConnect && onConnect()
          else
            onDisconnect && onDisconnect()
        })
      }
      else {
        onDisconnect && onDisconnect()
      }
    }
  )

react-native-offline

Handy toolbelt to deal with offline mode in React Native applications. Cross-platform, provides a smooth redux integration.

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis