Gathering detailed insights and metrics for cordova-plugin-device-motion
Gathering detailed insights and metrics for cordova-plugin-device-motion
Gathering detailed insights and metrics for cordova-plugin-device-motion
Gathering detailed insights and metrics for cordova-plugin-device-motion
npm install cordova-plugin-device-motion
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
Node Version
NPM Version
73 Stars
279 Commits
134 Forks
22 Watching
13 Branches
74 Contributors
Updated on 04 Jul 2024
JavaScript (62.56%)
Java (22.93%)
Objective-C (14.51%)
Cumulative downloads
Total Downloads
Last day
17.5%
201
Compared to previous day
Last week
-22.7%
976
Compared to previous week
Last month
-4.6%
4,748
Compared to previous month
Last year
-57.4%
113,260
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 accelerometer. The accelerometer is a motion sensor that detects the change (delta) in movement relative to the current device orientation, in three dimensions along the x, y, and z axis.
Access is via a global navigator.accelerometer
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.accelerometer);
}
Report issues with this plugin on the Apache Cordova issue tracker
cordova plugin add cordova-plugin-device-motion
Get the current acceleration along the x, y, and z axes.
These acceleration values are returned to the accelerometerSuccess
callback function.
navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
function onSuccess(acceleration) {
alert('Acceleration X: ' + acceleration.x + '\n' +
'Acceleration Y: ' + acceleration.y + '\n' +
'Acceleration Z: ' + acceleration.z + '\n' +
'Timestamp: ' + acceleration.timestamp + '\n');
}
function onError() {
alert('onError!');
}
navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
Values for X, Y, Z motion are all randomly generated in order to simulate the accelerometer.
The accelerometer is called with the SENSOR_DELAY_UI
flag, which limits the maximum readout frequency to something between 20 and 60 Hz, depending on the device. Values for period corresponding to higher frequencies will result in duplicate samples. More details can be found in the Android API Guide.
iOS doesn't recognize the concept of getting the current acceleration at any given point.
You must watch the acceleration and capture the data at given time intervals.
Thus, the getCurrentAcceleration
function yields the last value reported from a watchAccelerometer
call.
Retrieves the device's current Acceleration
at a regular interval, executing
the accelerometerSuccess
callback function each time. Specify the interval in
milliseconds via the acceleratorOptions
object's frequency
parameter.
The returned watch ID references the accelerometer's watch interval,
and can be used with navigator.accelerometer.clearWatch
to stop watching the
accelerometer.
var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,
accelerometerError,
accelerometerOptions);
function onSuccess(acceleration) {
alert('Acceleration X: ' + acceleration.x + '\n' +
'Acceleration Y: ' + acceleration.y + '\n' +
'Acceleration Z: ' + acceleration.z + '\n' +
'Timestamp: ' + acceleration.timestamp + '\n');
}
function onError() {
alert('onError!');
}
var options = { frequency: 3000 }; // Update every 3 seconds
var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
The API calls the success callback function at the interval requested, but restricts the range of requests to the device between 40ms and 1000ms. For example, if you request an interval of 3 seconds, (3000ms), the API requests data from the device every 1 second, but only executes the success callback every 3 seconds.
Stop watching the Acceleration
referenced by the watchID
parameter.
navigator.accelerometer.clearWatch(watchID);
navigator.accelerometer.watchAcceleration
.var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
// ... later on ...
navigator.accelerometer.clearWatch(watchID);
Contains Accelerometer
data captured at a specific point in time.
Acceleration values include the effect of gravity (9.81 m/s^2), so that when a
device lies flat and facing up, x, y, and z values returned should be
0
, 0
, and 9.81
.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
1 existing vulnerabilities detected
Details
Reason
Found 15/28 approved changesets -- score normalized to 5
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 2024-11-25
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