Device Orientation

Improve this doc

$ ionic plugin add cordova-plugin-device-orientation

Repo: https://github.com/apache/cordova-plugin-device-orientation

Requires Cordova plugin: cordova-plugin-device-orientation. For more info, please see the Device Orientation docs.

Usage

import {DeviceOrientation} from 'ionic-native';



// Get the device current compass heading
DeviceOrientation.getCurrentHeading().then(
  data => console.log(data),
  error => console.log(error)
);

// Watch the device compass heading change
var subscription = DeviceOrientation.watchHeading().subscribe(
  data => console.log(data)
);

// Stop watching heading change
subscription.unsubscribe();

Static Methods

getCurrentHeading()

Get the current compass heading.

Returns: Promise<CompassHeading>

watchHeading(options)

Get the device current heading at a regular interval

Stop the watch by unsubscribing from the observable

Param Type Details
options

Returns: Observable<CompassHeading>

API

Native

General