UNPKG

2.29 kBTypeScriptView Raw
1// Type definitions for Apache Cordova Network Information plugin
2// Project: https://github.com/apache/cordova-plugin-network-information
3// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5//
6// Copyright (c) Microsoft Open Technologies Inc
7// Licensed under the MIT license
8
9interface Navigator {
10 /**
11 * This plugin provides an implementation of an old version of the Network Information API.
12 * It provides information about the device's cellular and wifi connection, and whether the device has an internet connection.
13 */
14 connection: Connection;
15 // see https://github.com/apache/cordova-plugin-network-information/blob/dev/doc/index.md#api-change
16 // for
17 network: {
18 /**
19 * This plugin provides an implementation of an old version of the Network Information API.
20 * It provides information about the device's cellular and wifi connection, and whether the device has an internet connection.
21 */
22 connection: Connection
23 }
24}
25
26interface Document {
27 addEventListener(type: "online", connectionStateCallback: () => any, useCapture?: boolean): void;
28 addEventListener(type: "offline", connectionStateCallback: () => any, useCapture?: boolean): void;
29}
30
31/**
32 * The connection object, exposed via navigator.connection, provides information
33 * about the device's cellular and wifi connection.
34 */
35interface Connection {
36 /**
37 * This property offers a fast way to determine the device's network connection state, and type of connection.
38 * One of:
39 * Connection.UNKNOWN
40 * Connection.ETHERNET
41 * Connection.WIFI
42 * Connection.CELL_2G
43 * Connection.CELL_3G
44 * Connection.CELL_4G
45 * Connection.CELL
46 * Connection.NONE
47 */
48 type: string;
49 addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
50 removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
51}
52
53declare var Connection: {
54 UNKNOWN: string;
55 ETHERNET: string;
56 WIFI: string;
57 CELL_2G: string;
58 CELL_3G: string;
59 CELL_4G: string;
60 CELL: string;
61 NONE: string;
62}
\No newline at end of file