title: Taro.getBatteryInfo(option)
sidebar_label: getBatteryInfo
Obtains the device’s battery level. The synchronous API Taro.getBatteryInfoSync
is not available on iOS.
Reference
Type
(option?: Option) => void
Parameters
Option
Property |
Type |
Required |
Description |
complete |
(res: any) => void |
No |
The callback function used when the API call completed (always executed whether the call succeeds or fails) |
fail |
(res: any) => void |
No |
The callback function for a failed API call |
success |
(res: Result) => void |
No |
The callback function for a successful API call |
SuccessCallbackResult
Property |
Type |
Description |
isCharging |
boolean |
Indicates whether the device is charging. |
level |
string |
The device’s battery level. Range: 1-100. |
errMsg |
string |
Call result |
API Support
API |
WeChat Mini-Program |
H5 |
React Native |
Taro.getBatteryInfo |
✔️ |
|
|