NetInfo exposes info about online/offline status
ConnectionType
describes the type of connection the device is using to communicate with the network.
Cross platform values for ConnectionType
:
- none
- device is offline
- wifi
- device is online and connected via wifi, or is the iOS simulator
- cellular
- device is connected via Edge, 3G, WiMax, or LTE
- unknown
- error case and the network status is unknown
Android-only values for ConnectionType
:
- bluetooth
- device is connected via Bluetooth
- ethernet
- device is connected via Ethernet
- wimax
- device is connected via WiMAX
Cross platform values for EffectiveConnectionType
:
- 2g
- 3g
- 4g
- unknown
To request network info, you need to add the following line to your
app's AndroidManifest.xml
:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Available on Android. Detect if the current active connection is metered or not. A network is classified as metered when the user is sensitive to heavy data usage on that connection due to monetary costs, data limitations or battery/performance issues.
Available on all platforms. Asynchronously fetch a boolean to determine internet connectivity.
The following connectivity types are deprecated. They're used by the deprecated APIs fetch
and the change
event.
iOS connectivity types (deprecated):
- none
- device is offline
- wifi
- device is online and connected via wifi, or is the iOS simulator
- cell
- device is connected via Edge, 3G, WiMax, or LTE
- unknown
- error case and the network status is unknown
Android connectivity types (deprecated).
- NONE
- device is offline
- BLUETOOTH
- The Bluetooth data connection.
- DUMMY
- Dummy data connection.
- ETHERNET
- The Ethernet data connection.
- MOBILE
- The Mobile data connection.
- MOBILE_DUN
- A DUN-specific Mobile data connection.
- MOBILE_HIPRI
- A High Priority Mobile data connection.
- MOBILE_MMS
- An MMS-specific Mobile data connection.
- MOBILE_SUPL
- A SUPL-specific Mobile data connection.
- VPN
- A virtual network using one or more native bearers. Requires API Level 21
- WIFI
- The WIFI data connection.
- WIMAX
- The WiMAX data connection.
- UNKNOWN
- Unknown data connection.
The rest of the connectivity types are hidden by the Android API, but can be used if necessary.
Adds an event handler. Supported events:
connectionChange
: Fires when the network status changes. The argument to the event
handler is an object with keys:type
: A ConnectionType
(listed above)effectiveType
: An EffectiveConnectionType
(listed above)change
: This event is deprecated. Listen to connectionChange
instead. Fires when
the network status changes. The argument to the event handler is one of the deprecated
connectivity types listed above.Removes the listener for network status changes.
This function is deprecated. Use getConnectionInfo
instead. Returns a promise that
resolves with one of the deprecated connectivity types listed above.
Returns a promise that resolves to an object with type
and effectiveType
keys
whose values are a ConnectionType
and an EffectiveConnectionType
, (described above),
respectively.
An object with the same methods as above but the listener receives a boolean which represents the internet connectivity. Use this if you are only interested with whether the device has internet connectivity.
Improve this page by sending a pull request!