Skip to content

Commit

Permalink
feat(ios): Report IP address and subnet for ethernet (#233 by @gcesar…
Browse files Browse the repository at this point in the history
…mza)
  • Loading branch information
Gustavo Genovese authored and matt-oakes committed Nov 3, 2019
1 parent ceeb773 commit 507b731
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
5 changes: 4 additions & 1 deletion ios/RNCNetInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ - (NSDictionary *)currentDictionaryFromUpdateState:(RNCConnectionState *)state
if ([state.type isEqualToString:RNCConnectionTypeCellular]) {
details[@"cellularGeneration"] = state.cellularGeneration ?: NSNull.null;
details[@"carrier"] = [self carrier] ?: NSNull.null;
} else if ([state.type isEqualToString:RNCConnectionTypeWifi]) {
} else if (
[state.type isEqualToString:RNCConnectionTypeWifi] ||
[state.type isEqualToString:RNCConnectionTypeEthernet]
) {
details[@"ipAddress"] = [self ipAddress] ?: NSNull.null;
details[@"subnet"] = [self subnet] ?: NSNull.null;
}
Expand Down
6 changes: 6 additions & 0 deletions src/internal/__tests__/deprecatedUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ describe('Deprecated utils', () => {
isInternetReachable: true,
details: {
isConnectionExpensive: false,
ipAddress: '1.2.3.4',
subnet: '0.0.0.0',
},
},
isConnected: true,
Expand All @@ -86,6 +88,7 @@ describe('Deprecated utils', () => {
details: {
isConnectionExpensive: true,
cellularGeneration: NetInfoCellularGeneration['3g'],
carrier: 'carrier',
},
},
isConnected: true,
Expand All @@ -104,6 +107,7 @@ describe('Deprecated utils', () => {
details: {
isConnectionExpensive: true,
cellularGeneration: null,
carrier: 'carrier',
},
},
isConnected: true,
Expand Down Expand Up @@ -138,6 +142,8 @@ describe('Deprecated utils', () => {
isInternetReachable: true,
details: {
isConnectionExpensive: false,
ipAddress: '1.2.3.4',
subnet: '0.0.0.0',
},
},
isConnected: true,
Expand Down
15 changes: 13 additions & 2 deletions src/internal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,25 @@ export type NetInfoCellularState = NetInfoConnectedState<
NetInfoStateType.cellular,
{
cellularGeneration: NetInfoCellularGeneration | null;
carrier: string | null;
}
>;
export type NetInfoWifiState = NetInfoConnectedState<
NetInfoStateType.wifi,
{
ipAddress: string | null;
subnet: string | null;
}
>;
export type NetInfoWifiState = NetInfoConnectedState<NetInfoStateType.wifi>;
export type NetInfoBluetoothState = NetInfoConnectedState<
NetInfoStateType.bluetooth
>;
export type NetInfoEthernetState = NetInfoConnectedState<
NetInfoStateType.ethernet
NetInfoStateType.ethernet,
{
ipAddress: string | null;
subnet: string | null;
}
>;
export type NetInfoWimaxState = NetInfoConnectedState<NetInfoStateType.wimax>;
export type NetInfoVpnState = NetInfoConnectedState<NetInfoStateType.vpn>;
Expand Down

0 comments on commit 507b731

Please sign in to comment.