0
votes

It does not matter which function of the react-native-network-info I use, I always get a warning ([Unhandled promise rejection: TypeError: null is not an object (evaluating 'RNNetworkInfo.getGatewayIPAddress')]) and the function does not return anything. See code sample. I also already tried to do it exactly as in the documentation (https://www.npmjs.com/package/react-native-network-info):

// Get Default Gateway IP
NetworkInfo.getGatewayIPAddress().then(defaultGateway => {
  console.log(defaultGateway);
});
import { NetworkInfo } from "react-native-network-info";

 _updateStates = () => {
    ...
    ...

    NetworkInfo.getGatewayIPAddress((gateway) => {
      console.log(gateway);
    });
  };
2
is it logging undefined or something else ?nazmul
it is logging nothing but the warningNKurzweil

2 Answers

0
votes

You do not have added "then" in your code .Try this

_updateStates = () => {
    ...
    ...

    NetworkInfo.getGatewayIPAddress().then(gateway => {
     console.log(gateway);
    });
  };
0
votes

It seems , autolinking does not work properly for this library, i had to follow the following steps to make it work , enter image description here

It's noted in the documentation of the library for manual setup. But don't follow the 3rd step , otherwise your ios project won't build. I tried the following method from the library ,

NetworkInfo.getIPAddress().then((ipAddress) => {
      console.log(ipAddress);
    });

and it worked.