百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

react-native-network-info

> 前端框架
开源

用于获取设备网络信息的 React Native 库

370 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

用于获取设备网络信息的 React Native 库

react-native-network-info

React Native library for getting information about the devices network

Requirements

Version 3+ requires RN 0.47 or higher Version 2+ requires RN 0.40 - RN 0.46

Installation

javascript
npm install react-native-network-info --save

or

javascript
yarn add react-native-network-info

Linking the library

Using React Native >= 0.60

Linking the package manually is not required anymore with Autolinking.

iOS also requires CocoaPods install

$ cd ios && pod install && cd ..

Using React Native {

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); });


### Manually Linking the Library

If `react-native link` fails and you are not using the auto linking provided in React Native >= 0.60

### `iOS`

1. In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name]

2. Go to node_modules ➜ react-native-network-info and add the .xcodeproj file

3. Add `RNNetworkInfo.a` to `Build Phases -> Link Binary With Libraries`

Run your project (Cmd+R)

### `Android`

1. Add the following lines to `android/settings.gradle`:

   ```gradle
   include ':react-native-network-info'
   project(':react-native-network-info').projectDir = new File(settingsDir, '../node_modules/react-native-network-info/android')
  1. Update the android build tools version to 2.2.+ in android/build.gradle:
    gradle
    buildscript {
        ...
        dependencies {
            classpath 'com.android.tools.build:gradle:2.2.+' //  getPackages() {
            return Arrays.asList(
                new MainReactPackage(),
                new RNNetworkInfoPackage() // <-- add this line
            );
        }
    }

Dev Notes

Notes on how this package was made can be found here.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Candroidandroid-libraryiosios-lib

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架