Gathering detailed insights and metrics for cordova-plugin-device-orientation
Gathering detailed insights and metrics for cordova-plugin-device-orientation
Gathering detailed insights and metrics for cordova-plugin-device-orientation
Gathering detailed insights and metrics for cordova-plugin-device-orientation
cordova-plugin-screen-orientation
Cordova Screen Orientation plugin
@types/cordova-plugin-device-orientation
Stub TypeScript definitions entry for cordova-plugin-device-orientation, which provides its own types definitions
@awesome-cordova-plugins/device-orientation
Awesome Cordova Plugins - Native plugins for ionic apps
cordova-plugin-device-rotation
Gives Cordova developers information about device orientation: is it facing up or down?
Apache Cordova Device Orientation Plugin
npm install cordova-plugin-device-orientation
Typescript
Module System
Node Version
NPM Version
75.6
Supply Chain
99.5
Quality
83.4
Maintenance
100
Vulnerability
88
License
JavaScript (50.14%)
Objective-C (28.61%)
Java (21.25%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Apache-2.0 License
60 Stars
239 Commits
79 Forks
20 Watchers
12 Branches
67 Contributors
Updated on Jul 03, 2025
Latest Version
3.0.0
Package Id
cordova-plugin-device-orientation@3.0.0
Unpacked Size
70.68 kB
Size
17.65 kB
File Count
16
NPM Version
9.8.1
Node Version
18.18.2
Published on
Nov 05, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
With the W3C Device Orientation API, Android, iOS, and Windows devices may not need this plugin anymore.
However, on iOS 13+, potential issues with permissions and secure contexts can arise. Therefore it is recommended to use this plugin as it uses a native implementation.
This plugin provides access to the device's compass. The compass is a sensor that detects the direction or heading that the device is pointed, typically from the top of the device. It measures the heading in degrees from 0 to 359.99, where 0 is north.
Access is via a global navigator.compass
object.
Although the object is attached to the global scoped navigator
, it is not available until after the deviceready
event.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(navigator.compass);
}
Report issues on the Apache Cordova issue tracker
cordova plugin add cordova-plugin-device-orientation
Get the current compass heading. The compass heading is returned via a CompassHeading
object using the compassSuccess
callback function.
navigator.compass.getCurrentHeading(compassSuccess, compassError);
function onSuccess(heading) {
alert('Heading: ' + heading.magneticHeading);
};
function onError(error) {
alert('CompassError: ' + error.code);
};
navigator.compass.getCurrentHeading(onSuccess, onError);
Gets the device's current heading at a regular interval. Each time the heading
is retrieved, the headingSuccess
callback function is executed.
The returned watch ID references the compass watch interval. The watch
ID can be used with navigator.compass.clearWatch
to stop watching the navigator.compass.
var watchID = navigator.compass.watchHeading(compassSuccess, compassError, [compassOptions]);
compassOptions
may contain the following keys:
function onSuccess(heading) {
var element = document.getElementById('heading');
element.innerHTML = 'Heading: ' + heading.magneticHeading;
};
function onError(compassError) {
alert('Compass error: ' + compassError.code);
};
var options = {
frequency: 3000
}; // Update every 3 seconds
var watchID = navigator.compass.watchHeading(onSuccess, onError, options);
Values for current heading are randomly generated in order to simulate the compass.
Only one watchHeading
can be in effect at one time in iOS. If a
watchHeading
uses a filter, calling getCurrentHeading
or
watchHeading
uses the existing filter value to specify heading
changes. Watching heading changes with a filter is more efficient than
with time intervals.
filter
.Stop watching the compass referenced by the watch ID parameter.
navigator.compass.clearWatch(watchID);
navigator.compass.watchHeading
.var watchID = navigator.compass.watchHeading(onSuccess, onError, options);
// ... later on ...
navigator.compass.clearWatch(watchID);
A CompassHeading
object is returned to the compassSuccess
callback function.
magneticHeading: The heading in degrees from 0-359.99 at a single moment in time. (Number)
trueHeading: 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)
headingAccuracy: The deviation in degrees between the reported heading and the true heading. (Number)
timestamp: The time at which this heading was determined. (DOMTimeStamp)
The trueHeading
property is not supported, but reports the same value as magneticHeading
.
The headingAccuracy
property is always 0 because there is no difference between the magneticHeading
and trueHeading
.
trueHeading
property is only returned for location services enabled via navigator.geolocation.watchLocation()
.A CompassError
object is returned to the compassError
callback function when an error occurs.
CompassError.COMPASS_INTERNAL_ERR
CompassError.COMPASS_NOT_SUPPORTED
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
3 existing vulnerabilities detected
Details
Reason
Found 13/27 approved changesets -- score normalized to 4
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More