diff --git a/src/index.ts b/src/index.ts index 68268c46f..e030ed5ba 100644 --- a/src/index.ts +++ b/src/index.ts @@ -51,7 +51,7 @@ import {Keyboard} from './plugins/keyboard'; import {LaunchNavigator} from './plugins/launchnavigator'; import {LocalNotifications} from './plugins/localnotifications'; import {MediaPlugin} from './plugins/media'; -import {Network, Connection} from './plugins/network'; +import {Network} from './plugins/network'; import {OneSignal} from './plugins/onesignal'; import {Printer} from './plugins/printer'; import {Push} from './plugins/push'; @@ -107,7 +107,6 @@ export { BLE, BluetoothSerial, Clipboard, - Connection, DBMeter, Deeplinks, DeviceAccounts, @@ -158,7 +157,6 @@ window['IonicNative'] = { Camera: Camera, CardIO: CardIO, Clipboard: Clipboard, - Connection: Connection, Contacts: Contacts, DatePicker: DatePicker, DBMeter: DBMeter, diff --git a/src/plugins/network.ts b/src/plugins/network.ts index 25d2a4a82..43bbba3dd 100644 --- a/src/plugins/network.ts +++ b/src/plugins/network.ts @@ -10,7 +10,7 @@ declare var navigator: any; * * @usage * ```js - * import {Network, Connection} from 'ionic-native'; + * import {Network} from 'ionic-native'; * * // watch network for a disconnect * let disconnectSubscription = Network.onDisconnect().subscribe(() => { @@ -28,8 +28,7 @@ declare var navigator: any; *
// before we determine the connection type. Might need to wait
 * // prior to doing any api requests as well. * setTimeout(() => { - * console.log(Network.connection); - * if (Network.connection === Connection.WIFI) { + * if (Network.connection === 'wifi') { * console.log('we got a wifi connection, woohoo!'); * } * }, 3000); @@ -39,6 +38,8 @@ declare var navigator: any; * connectSubscription.unsubscribe(); * * ``` + * @advanced + * The `connection` property will return one of the following connection types: `unknown`, `ethernet`, `wifi`, `2g`, `3g`, `4g`, `cellular`, `none` */ @Plugin({ plugin: 'cordova-plugin-network-information', @@ -52,7 +53,7 @@ export class Network { * Return the network connection type */ @CordovaProperty - static get connection(): Connection { return navigator.connection.type; } + static get connection(): String { return navigator.connection.type; } /** * Get notified when the device goes offline @@ -75,18 +76,3 @@ export class Network { static onConnect(): Observable { return; } } - - -/** - * @private - */ -export class Connection { - static get UNKNOWN() { return 'unknown'; } - static get ETHERNET() { return 'ethernet'; } - static get WIFI() { return 'wifi'; } - static get CELL_2G() { return '2g'; } - static get CELL_3G() { return '3g'; } - static get CELL_4G() { return '4g'; } - static get CELL() { return 'cellular'; } - static get NONE() { return 'none'; } -}