react-native-connection-status
v1.1.2
Published
- React Native Bridge to check if device is able to access internet, since React Native NetInfo doesn't check if the user can access the internet, it only checks if the device is connected to a network
Downloads
5
Readme
react-native-connection-status
- React Native Bridge to check if device is able to access internet, since React Native NetInfo doesn't check if the user can access the internet, it only checks if the device is connected to a network
Getting started
$ npm install react-native-connection-status --save
Mostly automatic installation
$ react-native link react-native-connection-status
Manual installation
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNConnectionStatusPackage;
to the imports at the top of the file - Add
new RNConnectionStatusPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-connection-status' project(':react-native-connection-status').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-connection-status/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-connection-status')
iOS
In XCode, right-click the Libraries folder under your project ➜
Add Files to <your project>
Go to node_modules ➜ react-native-connection-status ➜ ios and add the
RNConnectionStatus.xcodeproj
fileGo to your apps project settings ➜ "Build Phases" ➜ "Link Binary With Libraries" and add
libRNConnectionStatus.a
from the linked project
Usage
import { hasInternetConnection } from 'react-native-connection-status';
const myCallback = console.log;
hasInternetConnection(myCallback);