1 | import { IonicNativePlugin } from '@ionic-native/core';
|
2 | import { Observable } from 'rxjs';
|
3 | export declare enum Connection {
|
4 | UNKNOWN = "unknown",
|
5 | ETHERNET = "ethernet",
|
6 | WIFI = "wifi",
|
7 | CELL_2G = "2g",
|
8 | CELL_3G = "3g",
|
9 | CELL_4G = "4g",
|
10 | CELL = "cellular",
|
11 | NONE = "none"
|
12 | }
|
13 | /**
|
14 | * @name Network
|
15 | * @premier network-information
|
16 | * @description
|
17 | * Requires Cordova plugin: cordova-plugin-network-information. For more info, please see the [Network plugin docs](https://github.com/apache/cordova-plugin-network-information).
|
18 | *
|
19 | * @usage
|
20 | * ```typescript
|
21 | * import { Network } from '@ionic-native/network/ngx';
|
22 | *
|
23 | * constructor(private network: Network) { }
|
24 | *
|
25 | * ...
|
26 | *
|
27 | * // watch network for a disconnection
|
28 | * let disconnectSubscription = this.network.onDisconnect().subscribe(() => {
|
29 | * console.log('network was disconnected :-(');
|
30 | * });
|
31 | *
|
32 | * // stop disconnect watch
|
33 | * disconnectSubscription.unsubscribe();
|
34 | *
|
35 | *
|
36 | * // watch network for a connection
|
37 | * let connectSubscription = this.network.onConnect().subscribe(() => {
|
38 | * console.log('network connected!');
|
39 | * // We just got a connection but we need to wait briefly
|
40 | * // before we determine the connection type. Might need to wait.
|
41 | * // prior to doing any api requests as well.
|
42 | * setTimeout(() => {
|
43 | * if (this.network.type === 'wifi') {
|
44 | * console.log('we got a wifi connection, woohoo!');
|
45 | * }
|
46 | * }, 3000);
|
47 | * });
|
48 | *
|
49 | * // stop connect watch
|
50 | * connectSubscription.unsubscribe();
|
51 | *
|
52 | * ```
|
53 | * @advanced
|
54 | * The `type` property will return one of the following connection types: `unknown`, `ethernet`, `wifi`, `2g`, `3g`, `4g`, `cellular`, `none`
|
55 | */
|
56 | export declare class NetworkOriginal extends IonicNativePlugin {
|
57 | /**
|
58 | * Constants for possible connection types
|
59 | */
|
60 | Connection: {
|
61 | UNKNOWN: string;
|
62 | ETHERNET: string;
|
63 | WIFI: string;
|
64 | CELL_2G: string;
|
65 | CELL_3G: string;
|
66 | CELL_4G: string;
|
67 | CELL: string;
|
68 | NONE: string;
|
69 | };
|
70 | /**
|
71 | * Connection type
|
72 | * @return {string}
|
73 | */
|
74 | type: string;
|
75 | /**
|
76 | * Downlink Max Speed
|
77 | * @return {string}
|
78 | */
|
79 | downlinkMax: string;
|
80 | /**
|
81 | * Returns an observable to watch connection changes
|
82 | * @return {Observable<'connected' | 'disconnected'>}
|
83 | */
|
84 | onChange(): Observable<'connected' | 'disconnected'>;
|
85 | /**
|
86 | * Get notified when the device goes offline
|
87 | * @returns {Observable<any>} Returns an observable.
|
88 | */
|
89 | onDisconnect(): Observable<any>;
|
90 | /**
|
91 | * Get notified when the device goes online
|
92 | * @returns {Observable<any>} Returns an observable.
|
93 | */
|
94 | onConnect(): Observable<any>;
|
95 | }
|
96 |
|
97 | export declare const Network: NetworkOriginal; |
\ | No newline at end of file |