(react-native) 如何检测 react native 中的电池电量? [英] (react-native) How to detect the battery level in react native?

查看:60
本文介绍了(react-native) 如何检测 react native 中的电池电量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要了解电池电量.如果基于此级别较低,我必须显示优化的组件.有没有办法像网络连接一样检测电池电量?

I need to get the battery level. If the level is low based upon that i have to show the optimised components. Is there a way to detect the battery level like network connection ?

推荐答案

我认为您将需要为此使用插件或编写本机模块.

I think you're going to need to use a plugin or write a native module for this.

https://github.com/oojr/react-native-battery是一个例子.

可用的 React Native API 列表位于 Dock 底部的左侧,目前似乎没有任何电源或电池.

The list of available react native API's are on the left hand side at the bottom of the dock, it looks like none expose any power or battery for now.

https://facebook.github.io/react-native/docs/actionsheetios.html

这篇关于(react-native) 如何检测 react native 中的电池电量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆