New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-native-battery-module

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-battery-module

A React Native module for getting battery information.

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

react-native-battery-module

Overview

The BatteryModule is a React Native library that provides easy access to battery information on mobile devices. It allows you to get the current battery level, check if the device is charging, and retrieve the battery status. This module is essential for applications that need to monitor battery performance or provide battery-related features.

Features

  • Get the current battery level as a percentage.
  • Check if the device is currently charging.
  • Retrieve detailed battery status (charging, discharging, full, etc.).

Installation

npm install react-native-battery-module

Usage

import {NativeModules} from 'react-native';
const {BatteryModule} = NativeModules;

const App = () => {
  const checkBatteryInfo = async () => {
    const batteryLevel = await BatteryModule.getBatteryLevel();
    console.log(`Battery Level: ${batteryLevel}%`);

    const charging = await BatteryModule.isCharging();
    console.log(`Is Charging: ${charging}`);

    const status = await BatteryModule.getBatteryStatus();
    console.log(`Battery Status: ${status}`);
  };

  useEffect(() => {
    checkBatteryInfo();
  }, []);

  return (
    <SafeAreaView style={styles.container}>
      {/* Your UI components */}
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});

Keywords

react-native

FAQs

Package last updated on 18 Sep 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