Scandit.NetworkInfo

Methods

(static) getConnectionStatus(): Promise

Returns the current connection status

Returns:
Promise

Promise which is resolved to the connection status name

Possible values: disconnected, cellular, wifi, other

Can return an error with code:

Examples
  • JavaScript
  • ES6
Scandit.NetworkInfo.getConnectionStatus()
.then(function(connectionStatus) {
  console.log('Connection status: ' + connectionStatus);
}.catch(console.error);
Scandit.NetworkInfo.getConnectionStatus()
.then(connectionStatus => {
  console.log(`Connection status: ${connectionStatus}`);
}.catch(console.error);

(static) getInternetStatus(): Promise

Returns the internet status

Returns:
Promise

Promise which is resolved to the internet status name

Possible values: online, offline

Can return an error with code:

Examples
  • JavaScript
  • ES6
Scandit.NetworkInfo.getInternetStatus()
.then(function(internetStatus) {
  console.log('The device is currently: ' + internetStatus);
}.catch(console.error);
Scandit.NetworkInfo.getInternetStatus()
.then(internetStatus => {
  console.log(`The device is currently: ${internetStatus}`);
}.catch(console.error);

(static) off(arg: (string | function))

Removes an event listener

Parameters:
Name Type Description
arg string | function

Event name or callback function

Examples
  • JavaScript
  • ES6
Scandit.NetworkInfo.off('connectionStatusChange');
Scandit.NetworkInfo.off('connectionStatusChange');

(static) on(event: string, callback: function)

Adds an event listener

Parameters:
Name Type Description
event string

Event name

callback function

Event callback

Examples
  • JavaScript
  • ES6
Scandit.NetworkInfo.on('internetStatusChange', function(newStatus) {
  if (newStatus === 'online') {
    console.log('The device is online now!');
  }
});
Scandit.NetworkInfo.on('internetStatusChange', newStatus => {
  if (newStatus === 'online') {
    console.log('The device is online now!');
  }
});

Events

connectionStatusChange

Connection status has changed, resolved to the name of the new status

Possible values: disconnected, cellular, wifi, other

internetStatusChange

Internet status has changed, resolved to the name of the new status

Possible values: online, offline