---
name: "onNetworkStatusChange"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "2.0.1" }
platform:
  - "iOS"
  - "Android"
async: true
---

## onNetworkStatusChange

> [VERSION] BaseKit >= 2.0.1

> [PLATFORM] iOS, Android

> ⚡ **Supports Promise** — Returns a Promise when success / fail / complete callbacks are omitted.

### Description

Listen for network status change events. Note: On Android, this event only notifies changes in network status. To obtain the latest network information, call the getNetworkType API again. Note: On Android, when the network changes, the system may not update the status immediately and there can be latency. Therefore, when this event is triggered, you may need to delay calling getNetworkType to get the latest information.

### Parameters

`(listener: Function)`

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `listener` | `(params: Object) => void` | Yes | - | Event listener callback function |

##### onNetworkStatusChange.listener(params) properties

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `isConnected` | `boolean` | Yes | - | `2.0.1` | Whether there is a network connection |
| `networkType` | `string` | Yes | - | `2.0.1` | Network type |


### Examples

```tsx
// Listen for network status changes; when switching networks (WiFi on/off or airplane mode), the callback returns connectivity and network type
ty.onNetworkStatusChange(e => {
  console.log("Network changed:", e.isConnected, e.networkType);
});
// State changes are triggered by switching networks; keep the listener active for a while
await new Promise(resolve => setTimeout(resolve, 8000));
```
