1.0.1 • Published 4 months ago

@speedchecker/react-native-plugin v1.0.1

Weekly downloads
-
License
BSD 3-Clause
Repository
github
Last release
4 months ago

npm version platforms License

React Native plugin for SpeedChecker SDK

SpeedChecker plugin allows developers to integrate speed test features into their own React Native apps. You can also try our native apps on Google Play and App Store, they are powered by the latest Speedchecker SDK versions. More information about SpeedChecker SDKs

Features

  • latency, download and upload speed of the user connection
  • robust measuring of cellular, wireless and even local network
  • testing details like the current speed and progress
  • additional information like network type and location (see KPI list below in FAQ)
  • included high-capacity servers provided and maintained by SpeedChecker or custom servers
  • detailed statistics and reports by SpeedChecker

Platform Support

AndroidiOS
supported :heavy_check_mark:supported :heavy_check_mark:

Requirements

  • Platform-specific requirements:
    • Android:
      • minSDK version: 21 or higher
      • Location permissions (for free users)
    • iOS:
      • Xcode 13.3.1 or later
      • Development Target 11.0 or later

Permission requirements

Free version of the plugin requires location permission to be able to perform a speed test. You need to handle location permission in your app level. Check out our location policy

Table of contents:

Getting started

Note: Make sure you have completed the React Native - Environment Setup instructions till "Creating a new application" step, before proceeding.

1. Create a React Native project

npx react-native init [project folder]

2. Go to project directory

cd [project folder]

3. Install the plugin from npm repository

npm i @speedchecker/react-native-plugin -- save

4. Link the plugin to your React Native project

npm link @speedchecker/react-native-plugin

5. Start the Metro Server

You will need to start Metro, the JavaScript bundler that ships with React Native.

To start Metro, run the following command from the root of your React Native project:

# using npm
npm start

# OR using Yarn
yarn start

6. Start your Application

Let Metro Bundler run in its own terminal. Open a new terminal from the root of your React Native project. Run the following command to start your Android or iOS app:

For Android

# using npm
npm run android

# OR using Yarn
yarn android

For iOS

# using npm
npm run ios

# OR using Yarn
yarn ios

If everything is set up correctly, you should see your new app running in your Android Emulator or iOS Simulator shortly provided you have set up your emulator/simulator correctly.

This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.

How to use

1. Import SpeedCheckerPlugin in your App.tsx file.

import SpeedCheckerPlugin from '@speedchecker/react-native-plugin';

2. Listen events from SpeedCheckerPlugin and all variables you need to store speed test results

const [status, setStatus] = useState('');
  const [ping, setPing] = useState('');
  const [currentSpeed, setCurrentSpeed] = useState('');
  const [download, setDownload] = useState('');
  const [upload, setUpload] = useState('');
  const [server, setServer] = useState('');
  const [connectionType, setConnectionType] = useState('');

  useEffect(() => {
    return () => {
      SpeedCheckerPlugin.removeTestStartedListener();
    };
  }, []);

3. To start speed test by event (e.g. button click), you need to import the plugin and add "startTest" method to your App.tsx file:

const startTest = () => {
    SpeedCheckerPlugin.addTestStartedListener((event: {
      status: React.SetStateAction<string>;
      ping: React.SetStateAction<string>;
      currentSpeed: React.SetStateAction<string>;
      downloadSpeed: React.SetStateAction<string>;
      uploadSpeed: React.SetStateAction<string>;
      server: React.SetStateAction<string>;
      connectionType: React.SetStateAction<string>;
     }) => {
      setStatus(event.status || '');
      setPing(event.ping);
      setCurrentSpeed(event.currentSpeed);
      setDownload(event.downloadSpeed);
      setUpload(event.uploadSpeed);
      setServer(event.server);
      setConnectionType(event.connectionType);
    });
    SpeedCheckerPlugin.startTest();
  };

4. If you are paid user, you should set license key before you start test. Please contact us and we will provide you with licenseKey for your app:

For Android

SpeedCheckerPlugin.setAndroidLicenseKey('Your license key')

For iOS

SpeedCheckerPlugin.setIosLicenseKey('Your license key')

If no license is set, test will be conducted in free mode and, as a result, request a location permission.

4. To stop speed test, add "stopTest" method to your App.tsx file:

 const stopTest = () => {
    SpeedCheckerPlugin.stopTest();
    setStatus('Speed Test stopped');
    SpeedCheckerPlugin.removeTestStartedListener();
  };

4. Modifying your App

Now that you have successfully run the app, let's modify it.

  1. Open App.tsx in your text editor of choice and edit some lines.
  2. For Android: Press the R key twice or select "Reload" from the Developer Menu (Ctrl + M (on Window and Linux) or Cmd ⌘ + M (on macOS)) to see your changes!

    For iOS: Hit Cmd ⌘ + R in your iOS Simulator to reload the app and see your changes!

Congratulations! :tada:

You've successfully run and modified your React Native App!

Uninstalling

To uninstall the plugin, run the following commands

npm unlink @speedchecker/react-native-plugin
npm uninstall @speedchecker/react-native-plugin --save

Now what?

Troubleshooting

If you can't get this to work, see the Troubleshooting page.

Learn More

To learn more about React Native, take a look at the following resources:

Demo application

Please check our demo application in React Native which includes basic speed test functionality.

License

SpeedChecker is offering different types of licenses:

ItemsFreeBasicAdvanced
Speed Test MetricsDownload / Upload / LatencyDownload / Upload / Latency / JitterDownload / Upload / Latency / Jitter
Accompanying MetricsDevice / Network KPIsDevice / Network KPIsDevice / Network KPIs / Advanced Cellular KPIs
Test Customization-test duration, multi-threading, warm-up phase etctest duration, multi-threading, warm-up phase etc
Location PermissionRequired location permissions--
Data Sharing RequirementRequired data sharing--
Measurement Servers-Custom measurement serversCustom measurement servers
Background and passive collection--Background and Passive data collection
CostFREECost: EnquireCost: Enquire

FAQ

Is the SDK free to use?

Yes! But the SDK collects data on network performance from your app and shares it with SpeedChecker and our clients. The free SDK version requires and enabled location. Those restrictions are not in the Basic and Advanced versions

Do you have also native SDKs?

Yes, we have both Android and iOS SDKs.

Do you provide other types of tests?

Yes! YouTube video streaming, Voice over IP and other tests are supported by our native SDK libraries. Check out our Android and iOS API documentation

Do you provide free support?

No, we provide support only on Basic and Advanced plans

What are all the metrics or KPIs that you can get using our native SDKs?

The free version of our plugin allows getting basic metrics which are described in this API documentation

Full list of our KPIs for Basic and Advanced versions

Do you host all infrastructure for the test?

Yes, you do not need to run any servers. We provide and maintain a network of high-quality servers and CDNs to ensure the testing is accurate. If you wish to configure your own server, this is possible on Basic and Advanced plans.

How do you measure the speed?

See our measurement methodology

What's next?

Please contact us for more details and license requirements.