首页 > 解决方案 > NetInfo.getConnectionInfo() 为 android 返回未知

问题描述

我正在使用以下代码获取连接信息,但它返回未知的 android:

componentDidMount() {
NetInfo.getConnectionInfo().then(connectionInfo => {
    console.log("Connection type", connectionInfo.type);
    console.log("Connection effective type", connectionInfo.effectiveType);
});}

我正在使用react-native-netinfo包来获取连接信息。

反应原生版本:0.59.0

标签: androidreact-native

解决方案


推荐阅读