
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
react-native-network-info
Advanced tools
React Native library for getting information about the devices network
Version 3+ requires RN 0.47 or higher Version 2+ requires RN 0.40 - RN 0.46
npm install react-native-network-info --save
or
yarn add react-native-network-info
Linking the package manually is not required anymore with Autolinking.
iOS
also requires CocoaPods install$ cd ios && pod install && cd ..
react-native link react-native-network-info
import { NetworkInfo } from "react-native-network-info";
// Get Local IP
NetworkInfo.getIPAddress().then(ipAddress => {
console.log(ipAddress);
});
// Get IPv4 IP (priority: WiFi first, cellular second)
NetworkInfo.getIPV4Address().then(ipv4Address => {
console.log(ipv4Address);
});
// Get Broadcast
NetworkInfo.getBroadcast().then(broadcast => {
console.log(broadcast);
});
// Get SSID
NetworkInfo.getSSID().then(ssid => {
console.log(ssid);
});
// Get BSSID
NetworkInfo.getBSSID().then(bssid => {
console.log(bssid);
});
// Get Subnet
NetworkInfo.getSubnet().then(subnet => {
console.log(subnet);
});
// Get Default Gateway IP
NetworkInfo.getGatewayIPAddress().then(defaultGateway => {
console.log(defaultGateway);
});
// Get frequency (supported only for Android)
NetworkInfo.getFrequency().then(frequency => {
console.log(frequency);
});
If react-native link
fails and you are not using the auto linking provided in React Native >= 0.60
iOS
In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name]
Go to node_modules ➜ react-native-network-info and add the .xcodeproj file
Add RNNetworkInfo.a
to Build Phases -> Link Binary With Libraries
Run your project (Cmd+R)
Android
Add the following lines to android/settings.gradle
:
include ':react-native-network-info'
project(':react-native-network-info').projectDir = new File(settingsDir, '../node_modules/react-native-network-info/android')
Update the android build tools version to 2.2.+
in android/build.gradle
:
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:2.2.+' // <- USE 2.2.+ version
}
...
}
...
Update the gradle version to 2.14.1
in android/gradle/wrapper/gradle-wrapper.properties
:
...
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
Add the compile line to the dependencies in android/app/build.gradle
:
dependencies {
...
compile project(':react-native-network-info')
}
Add the import and link the package in MainApplication.java
:
import com.pusherman.networkinfo.RNNetworkInfoPackage; // <-- add this import
public class MainApplication extends Application implements ReactApplication {
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNNetworkInfoPackage() // <-- add this line
);
}
}
Notes on how this package was made can be found here.
5.2.1 - 2019-09-23 (Yellow Check)
FAQs
Get local network information
We found that react-native-network-info demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.