【问题标题】:React Native wrapper for Connectivity Manager连接管理器的 React Native 包装器
【发布时间】:2018-07-30 01:30:14
【问题描述】:

我正在 RN 社区中寻找可以帮助我管理活动 wifi 连接的库。我想连接/断开某些 wifi 网络。

Java 中的等价类是: https://developer.android.com/reference/android/net/ConnectivityManager

【问题讨论】:

    标签: react-native networking automation android-wifi


    【解决方案1】:

    NetInfo 可能会解决您的问题。 这是一个例子 在这里找到更多https://facebook.github.io/react-native/docs/netinfo

    import {NetInfo} from 'react-native';
    
    NetInfo.getConnectionInfo().then((connectionInfo) => {
      console.log(
        'Initial, type: ' +
          connectionInfo.type +
          ', effectiveType: ' +
          connectionInfo.effectiveType,
      );
    });
    function handleFirstConnectivityChange(connectionInfo) {
      console.log(
        'First change, type: ' +
          connectionInfo.type +
          ', effectiveType: ' +
          connectionInfo.effectiveType,
      );
      NetInfo.removeEventListener(
        'connectionChange',
        handleFirstConnectivityChange,
      );
    }
    NetInfo.addEventListener('connectionChange', handleFirstConnectivityChange);
    

    【讨论】:

      猜你喜欢
      • 2020-07-29
      • 1970-01-01
      • 2016-12-19
      • 1970-01-01
      • 1970-01-01
      • 2011-07-03
      • 2021-04-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多