@spoonconsulting/capacitor-plugin-network-connectivity
v1.0.0
Published
Capacitor plugin that detects connection type and verifies actual internet access in real time.
Readme
@spoonconsulting/capacitor-plugin-network-connectivity
Capacitor plugin that detects connection type and verifies actual internet access in real time.
Install
To use npm
npm install @spoonconsulting/capacitor-plugin-network-connectivityTo use yarn
yarn add @spoonconsulting/capacitor-plugin-network-connectivitySync native files
npx cap syncAPI
getStatus()
getStatus() => Promise<InternetStatus>Read the current network status once.
Returns: Promise<InternetStatus>
Since: 0.0.1
addListener('internetStatusChange', ...)
addListener(eventName: 'internetStatusChange', listenerFunc: (status: InternetStatus) => void) => Promise<PluginListenerHandle>Emits internetStatusChange when connectivity, reachability, or connection type changes.
| Param | Type |
| ------------------ | ------------------------------------------------------------------------------ |
| eventName | 'internetStatusChange' |
| listenerFunc | (status: InternetStatus) => void |
Returns: Promise<PluginListenerHandle>
Since: 0.0.1
removeAllListeners()
removeAllListeners() => Promise<void>Remove all listeners for this plugin.
Since: 0.0.1
Interfaces
InternetStatus
| Prop | Type | Description |
| ----------------------- | -------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| connected | boolean | True when there is an active network path or interface (platform-specific). |
| internetReachable | boolean | True when the OS considers the network validated for general internet use. On Android this uses NET_CAPABILITY_VALIDATED; on iOS it follows NWPath satisfaction. |
| connectionType | 'wifi' | 'cellular' | 'none' | 'unknown' | Active transport when known: Wi‑Fi, cellular, none, or unknown. |
| state | 'offline' | 'limited' | 'online' | High-level state: fully offline, connected but not validated (limited), or online. |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
