Skip to content

hex-digital/capacitor-android-battery-settings

Repository files navigation

capacitor-android-battery-settings

Configure Android battery optimisation settings

Install

npm install capacitor-android-battery-settings
npx cap sync

Add the following to your AndroidManifest.xml above the <application> tag.

<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

API

isBatteryOptimizationEnabled()

isBatteryOptimizationEnabled() => Promise<{ isUnrestricted: boolean; }>

Returns: Promise<{ isUnrestricted: boolean; }>


requestBatteryOptimizationDisabled()

requestBatteryOptimizationDisabled() => Promise<void>