tencent cloud

Last updated: 2025-02-25 14:21:58
Battery
Last updated: 2025-02-25 14:21:58

getBatteryInfoSync

The utilization method for this API is Object wx.getBatteryInfoSync().
Function Description: The synchronous version of wx.getBatteryInfo.
Return Value: Object res.
Attributes
Types
Note
level
number
Device battery level, ranging from 1 - 100.
isCharging
boolean
Is the device currently charging?

getBatteryInfo

The method for utilizing this API is wx.getBatteryInfo(Object object).
Function Description: This function retrieves the device's battery level. The synchronous API wx.getBatteryInfoSync is not available on iOS.
Parameters and Description: Object object.
Attributes
Types
Default value
Required
Note
success
function
-
Not required
Callback function for successful interface invocation
fail
function
-
Not required
Callback function for unsuccessful interface invocation
complete
function
-
Not required
Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
object.success Callback Function Parameters: Object res.
Attributes
Types
Note
level
number
Device battery level, ranging from 1 - 100.
isCharging
boolean
Is the device currently charging?


Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback