ionic-native
Version:
Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support
75 lines (72 loc) • 2.22 kB
TypeScript
import { Observable } from 'rxjs/Observable';
/**
* @name Network
* @description
* Requires Cordova plugin: cordova-plugin-network-information. For more info, please see the [Network plugin docs](https://github.com/apache/cordova-plugin-network-information).
*
* @usage
* ```typescript
* import { Network } from 'ionic-native';
*
* // watch network for a disconnect
* let disconnectSubscription = Network.onDisconnect().subscribe(() => {
* console.log('network was disconnected :-(');
* });
*
* // stop disconnect watch
* disconnectSubscription.unsubscribe();
*
*
* // watch network for a connection
* let connectSubscription = Network.onConnect().subscribe(() => {
* console.log('network connected!');
* // We just got a connection but we need to wait briefly
*
// before we determine the connection type. Might need to wait
* // prior to doing any api requests as well.
* setTimeout(() => {
* if (Network.type === 'wifi') {
* console.log('we got a wifi connection, woohoo!');
* }
* }, 3000);
* });
*
* // stop connect watch
* connectSubscription.unsubscribe();
*
* ```
* @advanced
* The `type` property will return one of the following connection types: `unknown`, `ethernet`, `wifi`, `2g`, `3g`, `4g`, `cellular`, `none`
*/
export declare class Network {
/**
* Connection type
* @return {string}
*/
static type: string;
/**
* Downlink Max Speed
* @return {string}
*/
static downlinkMax: string;
/**
* Returns an observable to watch connection changes
* @return {Observable<any>}
*/
static onchange(): Observable<any>;
/**
* Returns an observable to watch connection type changes
* @return {Observable<any>}
*/
static ontypechange(): Observable<any>;
/**
* Get notified when the device goes offline
* @returns {Observable<any>} Returns an observable.
*/
static onDisconnect(): Observable<any>;
/**
* Get notified when the device goes online
* @returns {Observable<any>} Returns an observable.
*/
static onConnect(): Observable<any>;
}