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

device-info-manager

v1.0.0

Published

TODO

Downloads

2

Readme

React Native Library for Device Information

This project will give you device unique ID , current position, wifi connected information, available wifi connection.

Getting started

Installing it as a library in your main project

npm i device-info-manager
	or
yarn add device-info-manager
  1. Manually Linking the Library:

    Android

    • Add the following to android/settings.gradle:

      include ':device-info-manager'
      project(':device-info-manager').projectDir = new File(settingsDir, '../node_modules/device-info-manager/android')
    • Add the following to android/app/build.gradle:

           
      dependencies {
          ...
          implementation project(':device-info-manager')
      }
    • Add the following to android/app/src/main/java/**/MainApplication.java:

            
      import com.example.mylibrary.Package;
      
      public class MainApplication extends Application implements ReactApplication {
      
          @Override
          protected List<ReactPackage> getPackages() {
              return Arrays.<ReactPackage>asList(
                  new MainReactPackage(),
                  new Package()    
              );
          }
      }
    • For android you also need to put the following code to AndroidManifest.xml:

       <uses-permission android:required="true" android:name="android.permission.ACCESS_WIFI_STATE"/>
       <uses-permission android:required="true" android:name="android.permission.CHANGE_WIFI_STATE"/>    
       <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
       <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>  
       <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
  2. Simply import it by the name defined in your library's package.json:

    import nativeCalls from 'device-info-manager'; 

    Example:

    import React, { useState, useEffect } from 'react';
    import {
        ScrollView,
        View,
        Text,
        PermissionsAndroid
    } from 'react-native';
    
    import nativeCalls from 'device-info-manager';
    
    const App = () => {
    
    const [devicename, setDevieName] = useState("");
    const [devicenMacAddress, setDevieMacAddress] = useState("");
    const [latlong, setLatLong] = useState("");
    const [connectedTo, setConnectedTo] = useState("");
    const [connectedDeviceInfo, setConnectedDeviceInfo] = useState('');
    const [availableConnection, setAvailableConnection] = useState([]);
    
    
    const persmission = async () => {
        try {
        // permission to access location 
        const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION)
            .then(res => {
            if (res === "granted") {
                console.log(" permission!");
                nativeCalls.deviceNativeCall.loadWifiList(async (wifiStringList) => {
                var wifiArray = await JSON.parse(wifiStringList);
                setAvailableConnection(wifiArray);
    
                },
                (error) => {
                    console.log(error);
                })
    
                nativeCalls.wifiConnection.fetch().then(connection => {
                if (connection !== undefined) {
                    setConnectedTo(connection)
                }
    
                }).catch(err => {
                console.log("Error", err)
    
                })
            } else {
                console.log("You will not able to retrieve wifi available networks list");
            }
            });
        } catch (err) {
        console.warn(err)
        }
    }
    
    useEffect(() => {
        persmission();
        nativeCalls.deviceNativeCall.getCurrentPosition({
        enableHighAccuracy: true,
        timeout: 15000,
        })
        .then(async location => {
            setLatLong({ location })
        }).catch(error => {
            const { code, message } = error;
            console.warn(code, message);
        });
        nativeCalls.deviceNativeCall.getDeviceName((err, name) => {
        setDevieName(name);
        });
            <!-- specific to android -->
        nativeCalls.deviceNativeCall.getMacAddress((err, deviceMacAddress) => {
        setDevieMacAddress(deviceMacAddress);
        });
    
            <!-- specific to android -->
        nativeCalls.deviceNativeCall.getClientList((err, clientList) => {
        setConnectedDeviceInfo(clientList);
    
        });
    
    }, []);
    
    return (
        <ScrollView>
            <View style={{ margin: 10 }}>
                <Text>{"Device name: " + devicename + "\n"}</Text>
    
                <Text>{"Device mac address: " + devicenMacAddress + "\n"}</Text>
                {latlong.location !== undefined
                ? <Text>
                    {"latitude: " + latlong.location.latitude + " \nlongitude: " + latlong.location.longitude + " \ntime: " + latlong.location.time + "\n"}
                  </Text>
                : <Text>Wait</Text>}
    
            {connectedTo !== "" && connectedTo.type === 'wifi'
                ? <View>
                    <Text>{"connected type:   " + connectedTo.type}</Text>
                    <Text>{"isConnected:   " + connectedTo.isConnected}</Text>
                    <Text>{"isInternetReachable:   " + connectedTo.isInternetReachable}</Text>
                    <Text>{"isWifiEnabled:   " + connectedTo.isWifiEnabled}</Text>
    
                    <Text>{"bssid:   " + connectedTo.details.bssid}</Text>
                    <Text>{"frequency:   " + connectedTo.details.frequency}</Text>
                    <Text>{"ipAddress:   " + connectedTo.details.ipAddress}</Text>
                    <Text>{"isConnectionExpensive:   " + connectedTo.details.isConnectionExpensive}</Text>
                    <Text>{"ssid:   " + connectedTo.details.ssid}</Text>
                    <Text>{"strength:   " + connectedTo.details.strength}</Text>
                    <Text>{"subnet:   " + connectedTo.details.bssid + "\n"}</Text>
                </View>
                : connectedTo !== "" && connectedTo.type === 'cellular'
                ? <View>
                    <Text>{"connected to:   " + connectedTo.type}</Text>
    
                    <Text>{"carrier:   " + connectedTo.details.carrier}</Text>
                    <Text>{"cellularGeneration:   " + connectedTo.details.cellularGeneration}</Text>
                    <Text>{"isConnectionExpensive:   " + connectedTo.details.isConnectionExpensive + "\n"}</Text>
    
    
                    <Text>{"List of device connected to mobile hotspot:\n"}</Text>
                    <Text style={{ fontSize: 12 }}>{connectedDeviceInfo}</Text>
                 </View>
                : <Text>no connection found</Text>}
    
                <Text>{"Available wifi Connection: \n"}</Text>
                {availableConnection.length > 0
                ? availableConnection.map((list, i) => {
                    return (
                    <View key={i}>
                        <Text>{"BSSID:  " + list.BSSID}</Text>
                        <Text>{"SSID:   " + list.SSID}</Text>
                        <Text>{"capabilities:   " + list.capabilities}</Text>
                        <Text>{"frequency:  " + list.frequency}</Text>
                        <Text>{"level:  " + list.level}</Text>
                        <Text>{"timestamp:  " + list.timestamp + "\n"}</Text>
                    </View>
                    )
                })
                : <Text>No connection available</Text>}
    
            </View>
        </ScrollView>
        );
    };
    
    export default App;