Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-battery-optimization-android

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-battery-optimization-android

Battery optimization settings for react-native, android only

  • 0.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-47.06%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-battery-optimization-android

About

react-native disable or evade from Android's doze, standby mode.
Especially, Using Push Notification.

Installation

npm install react-native-battery-optimization-android

yarn add react-native-battery-optimization-android

Permissions

AndroidManifest.xml

 <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" android:minSdkVersion="29" />
 
 <uses-permission android:name="android.permission.POST_NOTIFICATIONS" android:minSdkVersion="33" />

Usage

import RnBatteryAndroid from 'react-native-battery-optimization-android';

function App() {

    useEffect(() => {
      RnBatteryAndroid?.getAppPackageName().then( (e) => console.log('packageName : ', e));  
    }, []);

    const openSettings = () => {
      RnBatteryAndroid?.openSettings();
    }

    const isWhiteListed = async () => {
          const result :boolean = await RnBatteryAndroid?.checkIsWhitelisted();
          ToastAndroid.show(`IsWhitelisted => ${result}`, ToastAndroid.TOP);
          if(!result)
          {
            try {
              RnBatteryAndroid?.checkBattery();
              RnBatteryAndroid?.requestIgnoreBatteryOptimizations();
            }
            catch(e)
            {
              console.log(e);
            }
          }
    }
    
    return (
        <View>...</View>
    )
}

APIs

NameReturnDesc
checkDrawOverlays()Promise boolean
requestDrawOverlays()Promise boolean
checkBatteryOptimizationPermission()Promise boolean
checkIsWhitelisted()Promise boolean
requestIgnoreBatteryOptimizations()void
openSettings()void
checkBattery()Promise stringCheck battery level
getAppPackageName()Promise stringProject package Name

License

Unlicense
We are not responsible for any losses incurred during use.

Made with create-react-native-library

Keywords

FAQs

Package last updated on 07 Dec 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc