1 | import { Observable } from 'rxjs/Observable';
|
2 | export interface DeviceOrientationCompassHeading {
|
3 | /**
|
4 | * The heading in degrees from 0-359.99 at a single moment in time. (Number)
|
5 | */
|
6 | magneticHeading: number;
|
7 | /**
|
8 | * The heading relative to the geographic North Pole in degrees 0-359.99 at a single moment in time. A negative value indicates that the true heading can't be determined. (Number)
|
9 | */
|
10 | trueHeading: number;
|
11 | /**
|
12 | * The deviation in degrees between the reported heading and the true heading. (Number)
|
13 | */
|
14 | headingAccuracy: number;
|
15 | /**
|
16 | * The time at which this heading was determined. (DOMTimeStamp)
|
17 | */
|
18 | timestamp: any;
|
19 | }
|
20 | export interface DeviceOrientationCompassOptions {
|
21 | /**
|
22 | * How often to retrieve the compass heading in milliseconds. (Number) (Default: 100)
|
23 | */
|
24 | frequency?: number;
|
25 | /**
|
26 | * The change in degrees required to initiate a watchHeading success callback. When this value is set, frequency is ignored. (Number)
|
27 | */
|
28 | filter?: number;
|
29 | }
|
30 | /**
|
31 | * @name Device Orientation
|
32 | * @description
|
33 | * Requires Cordova plugin: `cordova-plugin-device-orientation`. For more info, please see the [Device Orientation docs](https://github.com/apache/cordova-plugin-device-orientation).
|
34 | *
|
35 | * @usage
|
36 | * ```typescript
|
37 | * // DeviceOrientationCompassHeading is an interface for compass
|
38 | * import { DeviceOrientation, DeviceOrientationCompassHeading } from 'ionic-native';
|
39 | *
|
40 | *
|
41 | * // Get the device current compass heading
|
42 | * DeviceOrientation.getCurrentHeading().then(
|
43 | * (data: DeviceOrientationCompassHeading) => console.log(data),
|
44 | * (error: any) => console.log(error)
|
45 | * );
|
46 | *
|
47 | * // Watch the device compass heading change
|
48 | * var subscription = DeviceOrientation.watchHeading().subscribe(
|
49 | * (data: DeviceOrientationCompassHeading) => console.log(data)
|
50 | * );
|
51 | *
|
52 | * // Stop watching heading change
|
53 | * subscription.unsubscribe();
|
54 | * ```
|
55 | * @interfaces
|
56 | * DeviceOrientationCompassOptions
|
57 | * DeviceOrientationCompassHeading
|
58 | */
|
59 | export declare class DeviceOrientation {
|
60 | /**
|
61 | * Get the current compass heading.
|
62 | * @returns {Promise<DeviceOrientationCompassHeading>}
|
63 | */
|
64 | static getCurrentHeading(): Promise<DeviceOrientationCompassHeading>;
|
65 | /**
|
66 | * Get the device current heading at a regular interval
|
67 | *
|
68 | * Stop the watch by unsubscribing from the observable
|
69 | * @param {DeviceOrientationCompassOptions} options Options for compass. Frequency and Filter. Optional
|
70 | * @returns {Observable<DeviceOrientationCompassHeading>} Returns an observable that contains the compass heading
|
71 | */
|
72 | static watchHeading(options?: DeviceOrientationCompassOptions): Observable<DeviceOrientationCompassHeading>;
|
73 | }
|