npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@meduxspeedchecker/sdk-agent-cordova

v1.0.43

Published

Integrated solution with Medux SDK Agent for Cordova

Downloads

311

Readme

npm version platforms License

Cordova plugin for Medux SDK Agent

Integrated solution with Medux SDK Agent for Cordova (Apache Cordova) and Ionic Cordova applications

Release notes

v1.0.43

Android

  • Added config setting "isAutoSdkUpdateEnabled" to enable/disable Android SDK version auto-update. If this setting is true, the plugin will receive the latest available Speedchecker Android SDK version. To get the latest version, run console command "cordova prepare android" in your cordova project. If "isAutoSdkUpdateEnabled" is set to false, SDK version will remain the same all the time.

check out the Release history for more details

Table of contents:

Supported platforms

  • Android
  • iOS

Requirements

  • Permissions:

    • ACCESS_COARSE_LOCATION
    • ACCESS_FINE_LOCATION
    • ACCESS_BACKGROUND_LOCATION
  • Platform-specific requirements:

    • Android:
      • minSDK version: 22 or higher
      • Cordova Android version: android 11.x of higher
    • iOS:
      • Xcode 13.3.1 or later
      • Development Target 11.0 or later

Installing

1. Create a Cordova project

cordova create [project folder] app.medux.demo [name]

2. Go to project directory

cd [project folder]

3. Add your platform

cordova platform add [email protected]
cordova platform add ios

4. Add this configuration in the config.xml file of your Cordova project

  • Android:
<platform name="android">
        <config-file target="res/xml/config.xml" parent="/*">
            <feature name="SpeedCheckerPlugin" >
                <param name="android-package" value="org.apache.cordova.speedchecker.SpeedCheckerPlugin"/>
            </feature>
        </config-file>
        <source-file src="platforms/android/app/src/main/java/org/apache/cordova/speedchecker/SpeedCheckerPlugin.java" target-dir="src/org/apache/cordova/speedchecker" />
    </platform>
    <preference name="android-minSdkVersion" value="22" />
    <preference name="android-targetSdkVersion" value="31" />
    <preference name="android-compileSdkVersion" value="31" />
    
    // set to true to allow plugin receive latest SDK version, or set to false to keep the SDK version the same all the time
    <preference name="isAutoSdkUpdateEnabled" value="false" />
  • iOS
<!--Location permission keys-->
<config-file target="*-Info.plist" parent="NSLocationAlwaysAndWhenInUseUsageDescription">
    <string>your custom text here</string>
</config-file>
<config-file target="*-Info.plist" parent="NSLocationAlwaysUsageDescription">
    <string>your custom text here</string>
</config-file>
<config-file target="*-Info.plist" parent="NSLocationWhenInUseUsageDescription">
    <string>your custom text here</string>
</config-file>

<!--Background modes key-->
<config-file target="*-Info.plist" parent="UIBackgroundModes">
    <array>
        <string>location</string>
        <string>processing</string>
    </array>
</config-file>

<!--BGTaskSchedulerPermittedIdentifiers key-->
<config-file target="*-Info.plist" parent="BGTaskSchedulerPermittedIdentifiers">
    <array>
        <string>com.speedchecker.bgtests</string>
    </array>
</config-file>

<!--Background test setup keys-->
<config-file target="*-Info.plist" parent="SpeedCheckerBackgroundTestEnabledOnInit">
    <true/>
</config-file>

5. Install the plugin from npm repository

npm i @meduxspeedchecker/sdk-agent-cordova

6. Add the plugin to your Cordova project

cordova plugin add @meduxspeedchecker/sdk-agent-cordova

7. Prepare the project

cordova prepare android
cordova prepare ios

8. Run or emulate the project

cordova run android
cordova run ios
cordova emulate android
cordova emulate ios

How to use

Use the following (sample) functions in index.js:

To start speed test by event (e.g. button click):

Plugin includes "startTest" function, which has following signature:

startTest = function (
    onFinished,
    onError,
    onReceivedServers = function (obj) { },
    onPingStarted = function () { },
    onPingFinished = function (obj) { },
    onDownloadStarted = function () { },
    onDownloadProgress = function (obj) { },
    onDownloadFinished = function (obj) { },
    onUploadStarted = function () { },
    onUploadProgress = function (obj) { },
    onUploadFinished = function (obj) { },
) {...}

You need to implement these functions in index.js, similar to these sample functions startSpeedTest() and setStatus() below:

function startSpeedTest() {

    setStatus("Test started");
    SpeedCheckerPlugin.startTest(
        // onFinished
        function(obj) {
            console.log(JSON.stringify(obj));
            setStatus('Test finished <br>ping: ' + obj.ping.toFixed() + ' ms<br> packetLoss: ' + obj.packetLoss.toFixed() +  '<br>download speed: ' + obj.downloadSpeed.toFixed(2) + ' Mbps' + '<br>upload speed: ' + obj.uploadSpeed.toFixed(2) + ' Mbps<br> jitter: ' + obj.jitter + '<br>connectionType: ' + obj.connectionType + '<br>server: ' + obj.server + '<br>ip: ' + obj.ipAddress + '<br>isp: ' + obj.ispName + '<br>timestamp: ' + obj.timestamp);
        },
        //onError
        function(err) {
            console.log(err);
            setStatus('error code: ' + err.code);
        },
        //onReceivedServers
        function(obj) {
            console.log(JSON.stringify(obj));
            setStatus('Received servers');
        },
        //onPingStarted
        function() {
            console.log('Ping started');
            setStatus('Ping started');
        },
        //onPingFinished
        function(obj) {
            console.log(JSON.stringify(obj));
            setStatus('Ping: ' + obj.ping.toFixed() + ' ms');
        },
        //onDownloadStarted
        function() {
            console.log('Download started');
            setStatus('Download started');
        },
        //onDownloadProgress
        function(obj) {
            console.log(JSON.stringify(obj));
            setStatus('Download progress: ' + obj.progress.toFixed(0) + ' %' + '<br>speed: ' + obj.downloadSpeed.toFixed(2) + ' Mbps');
        },
        //onDownloadFinished
        function(obj) {
            console.log(JSON.stringify(obj));
            setStatus('Download speed: ' + obj.downloadSpeed.toFixed(2) + ' Mbps');
        },
        //onUploadStarted
        function() {
            console.log('Upload started');
            setStatus('Upload started');
        },
        //onUploadProgress
        function(obj) {
            console.log(JSON.stringify(obj));
            setStatus('Upload progress: ' + obj.progress.toFixed(0) + ' %' + '<br>speed: ' + obj.uploadSpeed.toFixed(2) + ' Mbps');
        },
        //onUploadFinished
        function(obj) {
            console.log(JSON.stringify(obj));
            setStatus('Upload speed: ' + obj.uploadSpeed.toFixed(2) + ' Mbps');
        }
    )
}

function setStatus(text) {
    document.getElementById("log").innerHTML = text;
}

To enable/disable background network test:

function setBackgroundNetworkTesting(isEnabled) {
    SpeedCheckerPlugin.setBackgroundNetworkTesting(
        isEnabled,
        function(err) {
            console.log(err);
        }
    )
}

To receive background network test status:

function getBackgroundNetworkTestingEnabled() {
    SpeedCheckerPlugin.getBackgroundNetworkTestingEnabled(
        function(enabled) {
            console.log('Background tests enabled: ' + enabled);
        },
        function(err) {
            console.log(err);
        }
    )
}

To set/get/remove MSISDN value:

function getMSISDN() {
    SpeedCheckerPlugin.getMSISDN(
        function(msisdn) {
            console.log('Current MSISDN is ' + msisdn);
        },
        function(err) {
            console.log(err);
        }
    )
}

function setMSISDN(value) {
    SpeedCheckerPlugin.setMSISDN(
        value,
        function(err) {
            console.log(err);
        }
    )
}

function removeMSISDN() {
    setMSISDN(null);
}

To set/get/remove UserID value:

function getUserID() {
    SpeedCheckerPlugin.getUserID(
        function(userID) {
            console.log('Current UserID is ' + userID);
        },
        function(err) {
            console.log(err);
        }
    )
}

function setUserID(value) {
    SpeedCheckerPlugin.setUserID(
        value,
        function(err) {
            console.log(err);
        }
    )
}

function removeUserID() {
    setUserID(null);
}

To get DeviceUniqueID value:

function getDeviceUniqueID() {
    SpeedCheckerPlugin.getUniqueID(
        function(uniqueID) {
            console.log('Current Unique deviceID is ' + uniqueID);
        },
        function(err) {
            console.log(err);
        }
    )
}

Updating

To update the plugin, install it again from npm repository with the following commands

npm i @meduxspeedchecker/sdk-agent-cordova
cordova plugin add @meduxspeedchecker/sdk-agent-cordova

To check all installed plugins and their current version in your project, run the following commands

cordova plugin list

Uninstalling

To uninstall the plugin, run the following commands

npm uninstall @meduxspeedchecker/sdk-agent-cordova
cordova plugin remove sdk-agent-cordova