1.0.2 • Published 10 months ago

react-native-battery-module v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

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',
  },
});
1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago