1 | import { Observable } from 'rxjs/Observable';
|
2 | /**
|
3 | * @name Network
|
4 | * @description
|
5 | * Requires Cordova plugin: cordova-plugin-network-information. For more info, please see the [Network plugin docs](https://github.com/apache/cordova-plugin-network-information).
|
6 | *
|
7 | * @usage
|
8 | * ```typescript
|
9 | * import { Network } from 'ionic-native';
|
10 | *
|
11 | * // watch network for a disconnect
|
12 | * let disconnectSubscription = Network.onDisconnect().subscribe(() => {
|
13 | * console.log('network was disconnected :-(');
|
14 | * });
|
15 | *
|
16 | * // stop disconnect watch
|
17 | * disconnectSubscription.unsubscribe();
|
18 | *
|
19 | *
|
20 | * // watch network for a connection
|
21 | * let connectSubscription = Network.onConnect().subscribe(() => {
|
22 | * console.log('network connected!');
|
23 |
|
24 | * // We just got a connection but we need to wait briefly
|
25 | *
|
26 | // before we determine the connection type. Might need to wait
|
27 |
|
28 | * // prior to doing any api requests as well.
|
29 | * setTimeout(() => {
|
30 | * if (Network.type === 'wifi') {
|
31 | * console.log('we got a wifi connection, woohoo!');
|
32 | * }
|
33 | * }, 3000);
|
34 | * });
|
35 | *
|
36 | * // stop connect watch
|
37 | * connectSubscription.unsubscribe();
|
38 | *
|
39 | * ```
|
40 | * @advanced
|
41 | * The `type` property will return one of the following connection types: `unknown`, `ethernet`, `wifi`, `2g`, `3g`, `4g`, `cellular`, `none`
|
42 | */
|
43 | export declare class Network {
|
44 | /**
|
45 | * Connection type
|
46 | * @return {string}
|
47 | */
|
48 | static type: string;
|
49 | /**
|
50 | * Downlink Max Speed
|
51 | * @return {string}
|
52 | */
|
53 | static downlinkMax: string;
|
54 | /**
|
55 | * Returns an observable to watch connection changes
|
56 | * @return {Observable<any>}
|
57 | */
|
58 | static onchange(): Observable<any>;
|
59 | /**
|
60 | * Returns an observable to watch connection type changes
|
61 | * @return {Observable<any>}
|
62 | */
|
63 | static ontypechange(): Observable<any>;
|
64 | /**
|
65 | * Get notified when the device goes offline
|
66 | * @returns {Observable<any>} Returns an observable.
|
67 | */
|
68 | static onDisconnect(): Observable<any>;
|
69 | /**
|
70 | * Get notified when the device goes online
|
71 | * @returns {Observable<any>} Returns an observable.
|
72 | */
|
73 | static onConnect(): Observable<any>;
|
74 | }
|