react-native-internet-speed
v1.0.3
Published
get network speed for IOS, Android
Downloads
253
Maintainers
Readme
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
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-internet-speed
and addRNInternetSpeed.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNInternetSpeed.a
to your project'sBuild Phases
➜Link 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 thegetPackages()
method
- Add
- 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();