6.0.0 • Published 14 days ago

@capacitor/network v6.0.0

Weekly downloads
457
License
MIT
Repository
github
Last release
14 days ago

@capacitor/network

The Network API provides network and connectivity information.

Install

npm install @capacitor/network
npx cap sync

Example

import { Network } from '@capacitor/network';

Network.addListener('networkStatusChange', status => {
  console.log('Network status changed', status);
});

const logCurrentNetworkStatus = async () => {
  const status = await Network.getStatus();

  console.log('Network status:', status);
};

API

getStatus()

getStatus() => Promise<ConnectionStatus>

Query the current status of the network connection.

Returns: Promise<ConnectionStatus>

Since: 1.0.0


addListener('networkStatusChange', ...)

addListener(eventName: 'networkStatusChange', listenerFunc: ConnectionStatusChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle

Listen for changes in the network connection.

ParamType
eventName'networkStatusChange'
listenerFuncConnectionStatusChangeListener

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 1.0.0


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners (including the network status changes) for this plugin.

Since: 1.0.0


Interfaces

ConnectionStatus

Represents the state and type of the network connection.

PropTypeDescriptionSince
connectedbooleanWhether there is an active connection or not.1.0.0
connectionTypeConnectionTypeThe type of network connection currently in use. If there is no active network connection, connectionType will be 'none'.1.0.0

PluginListenerHandle

PropType
remove() => Promise<void>

Type Aliases

ConnectionType

The type of network connection that a device might have.

'wifi' | 'cellular' | 'none' | 'unknown'

ConnectionStatusChangeListener

Callback to receive the status change notifications.

(status: ConnectionStatus): void

6.0.0

24 days ago

6.0.0-rc.1

2 months ago

6.0.0-rc.0

3 months ago

5.0.7

3 months ago

6.0.0-beta.1

5 months ago

6.0.0-beta.0

5 months ago

6.0.0-alpha.1

6 months ago

6.0.0-alpha.2

6 months ago

5.0.6

10 months ago

5.0.5

11 months ago

5.0.4

11 months ago

5.0.2

1 year ago

5.0.1

1 year ago

5.0.0

1 year ago

5.0.0-beta.1

1 year ago

5.0.0-beta.0

1 year ago

5.0.0-alpha.1

1 year ago

4.1.0

1 year ago

4.0.0-beta.2

2 years ago

4.0.0-beta.0

2 years ago

4.0.1

2 years ago

4.0.0

2 years ago

1.0.7

2 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

0.4.10

3 years ago

1.0.0

3 years ago

0.4.9

3 years ago

0.4.8

3 years ago

0.4.7

3 years ago

0.4.6

3 years ago

0.4.5

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.1

4 years ago