Reputation: 324
I'm developing a mobile application using Expo framework(react native).
I need to find the device's local IP address in order to connect to a specific device on the intranet.
Please guide me through this task.
Thanks
Upvotes: 5
Views: 6044
Reputation: 4703
You can use Expo Network.getIpAddressAsync() which returns a Promise, so you need to resolve it first.
Here is an example:
import * as Network from 'expo-network';
const ipAlert = async () => {
const ip = await Network.getIpAddressAsync()
alert(ip);
};
ipAlert();
Upvotes: 3
Reputation: 11950
https://docs.expo.io/versions/latest/sdk/network/#networkgetipaddressasync
await Network.getIpAddressAsync();
// "92.168.32.44
Upvotes: 3