Since

0.1

Device.Network provides several information about the network connections and adaptors on the device.

Example

import Network from '@smartface/native/device/network';
console.log("Device.Network.IMSI: " + Network.IMSI);
console.log("Device.Network.SMSEnabled: " + Network.SMSEnabled);
console.log("Device.Network.bluetoothMacAddress: " + Network.bluetoothMacAddress);
console.log("Device.Network.carrier: " + Network.carrier);
console.log("Device.Network.connectionType: " + Network.connectionType);
console.log("Device.Network.roamingEnabled: " + Network.roamingEnabled);
console.log("Device.Network.connectionIP: " + Network.connectionIP);
console.log("Device.Network.wirelessMacAddress: " + Network.wirelessMacAddress);

Hierarchy

  • INetwork

Properties

Notifier: ConstructorOf<INetworkNotifier, Partial<INetworkNotifier>>

Since

3.0.1

Provides an event to notify in case of connection is changed. In Android, notifier fires the subscribed event with cached value at the first launch. That enables to not miss any changes. Such as, changed value could be missed when application is frozen. However it can be checked by Device.Network.createNotifier#isInitialStickyNotification isInitialStickyNotification .

Example

import Network from '@smartface/native/device/network';
var notifier = new Network.Notifier();

notifier.subscribe(function(connectionType) {
console.log("ConnectionType is " + connectionType);
});

Since

3.0.1

Provides an event to notify in case of connection is changed. In Android, notifier fires the subscribed event with cached value at the first launch. That enables to not miss any changes. Such as, changed value could be missed when application is frozen. However it can be checked by Device.Network.createNotifier#isInitialStickyNotification isInitialStickyNotification .

Example

import Network from '@smartface/native/device/network';
var notifier = new Network.Notifier();

notifier.subscribe(function(connectionType) {
console.log("ConnectionType is " + connectionType);
});
roamingEnabled: boolean

Returns whether roaming is enabled on the device

Property

Static

Since

0.1

ConnectionType: typeof ConnectionType

Determines whether the current internet connection is made through wireless, cellular or other Does not determine if the device is actually conntected to the internet. E.g. you could be connected to Wi-Fi but you don't have an IP address. You should ping somewhere (like https://smartface.io) to actually measure if the device is connected to the internet. .

Accessors

  • get carrier(): string
  • Returns the carrier name of the GSM connection.

    Property

    Static

    Since

    0.1

    Returns string

  • get connectionType(): ConnectionType
  • Returns the current connection type.

    Property

    Static

    Since

    0.1

    Returns ConnectionType

  • get connectionIP(): string
  • Returns the IP address of the current connection.

    Property

    Static

    Since

    0.1

    Returns string

  • get SMSEnabled(): boolean
  • Returns if the device is capable of SMS operations.

    Property

    Static

    Since

    0.1

    Returns boolean

  • get IMSI(): string
  • Returns the 'International Mobile Subscriber Identity' of the device. Requires the Permissions.android#phone
    If your app runs on Android 10 (API level 29) or above, a SecurityException occurs.

    Property

    Deprecated

    Static

    Since

    0.1

    Returns string

  • get bluetoothMacAddress(): string
  • Returns the MAC address of the bluetooth adaptor on the device. This requires the Permissions.android#bluetoothConnect permission.

    Property

    Static

    Since

    0.1

    Returns string

  • get wirelessMacAddress(): string
  • Returns the MAC address of the wireless adaptor on the device.

    Property

    Static

    Since

    0.1

    Returns string

Methods

  • Stops listening to any active notifier listeners.

    Returns void

  • Checks whether the device is connected to the internet right now. It will ping the given checkUrl parameter. Uses google.com if no parameter is given.

    Method

    Static

    Returns

    • Resolves if the internet connectivity is available, rejects o/w

    Example

    import Network from '@smartface/native/device/network';
    Network.isConnected("myprivatenetwork.com");
    .then(() => {
    console.info("Connected to internet");
    })
    .catch(() => {
    console.error("Not connected to internet");
    });

    Parameters

    • Optional checkUrl: string

      Used URL for check the internet

    Returns Promise<void>

Generated using TypeDoc