ionic-native
Version:
Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support
74 lines (73 loc) • 2.81 kB
TypeScript
import { Observable } from 'rxjs/Observable';
export interface DeviceOrientationCompassHeading {
/**
* The heading in degrees from 0-359.99 at a single moment in time. (Number)
*/
magneticHeading: number;
/**
* 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)
*/
trueHeading: number;
/**
* The deviation in degrees between the reported heading and the true heading. (Number)
*/
headingAccuracy: number;
/**
* The time at which this heading was determined. (DOMTimeStamp)
*/
timestamp: any;
}
export interface DeviceOrientationCompassOptions {
/**
* How often to retrieve the compass heading in milliseconds. (Number) (Default: 100)
*/
frequency?: number;
/**
* The change in degrees required to initiate a watchHeading success callback. When this value is set, frequency is ignored. (Number)
*/
filter?: number;
}
/**
* @name Device Orientation
* @description
* Requires Cordova plugin: `cordova-plugin-device-orientation`. For more info, please see the [Device Orientation docs](https://github.com/apache/cordova-plugin-device-orientation).
*
* @usage
* ```typescript
* // DeviceOrientationCompassHeading is an interface for compass
* import { DeviceOrientation, DeviceOrientationCompassHeading } from 'ionic-native';
*
*
* // Get the device current compass heading
* DeviceOrientation.getCurrentHeading().then(
* (data: DeviceOrientationCompassHeading) => console.log(data),
* (error: any) => console.log(error)
* );
*
* // Watch the device compass heading change
* var subscription = DeviceOrientation.watchHeading().subscribe(
* (data: DeviceOrientationCompassHeading) => console.log(data)
* );
*
* // Stop watching heading change
* subscription.unsubscribe();
* ```
* @interfaces
* DeviceOrientationCompassOptions
* DeviceOrientationCompassHeading
*/
export declare class DeviceOrientation {
/**
* Get the current compass heading.
* @returns {Promise<DeviceOrientationCompassHeading>}
*/
static getCurrentHeading(): Promise<DeviceOrientationCompassHeading>;
/**
* Get the device current heading at a regular interval
*
* Stop the watch by unsubscribing from the observable
* @param {DeviceOrientationCompassOptions} options Options for compass. Frequency and Filter. Optional
* @returns {Observable<DeviceOrientationCompassHeading>} Returns an observable that contains the compass heading
*/
static watchHeading(options?: DeviceOrientationCompassOptions): Observable<DeviceOrientationCompassHeading>;
}