# uni.getBatteryInfo(OBJECT)

Get device power

This API is uni ext api, you need to download the plug-in: [getBatteryInfo](https://ext.dcloud.net.cn/plugin ?id=9295)

uni ext api requires HBuilderX 3.6.8+

iOS requires a custom dock

App H5 微信小程序 支付宝小程序 百度小程序 抖音小程序 飞书小程序 QQ小程序 快手小程序 京东小程序 元服务 小红书小程序
x x x x 1.0.4+ 支持 Sync x

# getBatteryInfo 兼容性

HarmonyOS
HBuilderX 4.23

OBJECT parameter description

Parameter Name Type Required Description
success Function No Callback for successful interface call
fail Function No Callback function for interface call failure
complete Function No The callback function for the end of the interface call (it will be executed when the call succeeds or fails)

success return parameter description

Parameter Type Description
level Number Equipment level, range 1 - 100
isCharging Boolean Whether it is charging

Example Code

uni.getBatteryInfo({
  success: (res) => {
    console.log(res)
  }
})