1 | import { Observable } from 'rxjs/Observable';
|
2 | export interface BatteryStatusResponse {
|
3 | /**
|
4 | * The battery charge percentage
|
5 | */
|
6 | level: number;
|
7 | /**
|
8 | * A boolean that indicates whether the device is plugged in
|
9 | */
|
10 | isPlugged: boolean;
|
11 | }
|
12 | /**
|
13 | * @name Battery Status
|
14 | * @description
|
15 | * Requires Cordova plugin: cordova-plugin-batterystatus. For more info, please see the [BatteryStatus plugin docs](https://github.com/apache/cordova-plugin-battery-status).
|
16 | *
|
17 | * @usage
|
18 | * ```typescript
|
19 | * import { BatteryStatus } from 'ionic-native';
|
20 | *
|
21 | *
|
22 | * // watch change in battery status
|
23 | * let subscription = BatteryStatus.onChange().subscribe(
|
24 | * (status: StatusObject) => {
|
25 | * console.log(status.level, status.isPlugged);
|
26 | * }
|
27 | * );
|
28 | *
|
29 | * // stop watch
|
30 | * subscription.unsubscribe();
|
31 | *
|
32 | * ```
|
33 | * @interfaces
|
34 | * BatteryStatusResponse
|
35 | */
|
36 | export declare class BatteryStatus {
|
37 | /**
|
38 | * Watch the change in battery level
|
39 | * @returns {Observable<BatteryStatusResponse>} Returns an observable that pushes a status object
|
40 | */
|
41 | static onChange(): Observable<BatteryStatusResponse>;
|
42 | /**
|
43 | * Watch when the battery level goes low
|
44 | * @returns {Observable<BatteryStatusResponse>} Returns an observable that pushes a status object
|
45 | */
|
46 | static onLow(): Observable<BatteryStatusResponse>;
|
47 | /**
|
48 | * Watch when the battery level goes to critial
|
49 | * @returns {Observable<BatteryStatusResponse>} Returns an observable that pushes a status object
|
50 | */
|
51 | static onCritical(): Observable<BatteryStatusResponse>;
|
52 | }
|