🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

react-native-internet-speed

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-internet-speed

get network speed for IOS, Android

1.0.3
latest
Version published
Weekly downloads
6
-33.33%
Maintainers
1
Weekly downloads
 
Created

react-native-internet-speed

  • This module can obtain the network speed of the current device.
  • for IOS : currently only the network speed of the entire device can be obtained

Getting started

npm install react-native-internet-speed --save

or

yarn add react-native-internet-speed

Mostly automatic installation

react-native link react-native-internet-speed

Manual installation

iOS

  • In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  • Go to node_modulesreact-native-internet-speed and add RNInternetSpeed.xcodeproj
  • In XCode, in the project navigator, select your project. Add libRNInternetSpeed.a to your project's Build PhasesLink Binary With Libraries
  • Run your project (Cmd+R)<

Android

  • Open up android/app/src/main/java/[...]/MainActivity.java
    • Add import com.sstatsuya.internetspeed.RNInternetSpeedPackage; to the imports at the top of the file
    • Add new RNInternetSpeedPackage() to the list returned by the getPackages() method
  • Append the following lines to android/settings.gradle:
    include ':react-native-internet-speed'
    project(':react-native-internet-speed').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-internet-speed/android')
    
  • Insert the following lines inside the dependencies block in android/app/build.gradle:
        compile project(':react-native-internet-speed')
    

Usage

import InternetSpeed from "react-native-internet-speed";
// start
InternetSpeed.startListenInternetSpeed(
  ({
    downLoadSpeed,
    downLoadSpeedCurrent,
    upLoadSpeed,
    upLoadSpeedCurrent,
  }) => {
    console.log(downLoadSpeed + "kb/s"); // download speed for the entire device The download speed of the entire device
    console.log(downLoadSpeedCurrent + "kb/s"); // download speed for the current app The download speed of the current app (currently can only be used on Android)
    console.log(upLoadSpeed + "kb/s"); // upload speed for the entire device The upload speed of the entire device
    console.log(upLoadSpeedCurrent + "kb/s"); // upload speed for the current app The upload speed of the current app (currently can only be used on Android)
  }
);
// stop
InternetSpeed.stopListenInternetSpeed();

FAQs

Package last updated on 05 Mar 2024

Did you know?

Socket

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.

Install

Related posts