{"id":14988023,"url":"https://github.com/apache/cordova-plugin-device-motion","last_synced_at":"2025-04-04T11:17:00.249Z","repository":{"id":9085296,"uuid":"10860594","full_name":"apache/cordova-plugin-device-motion","owner":"apache","description":"Apache Cordova Device Motion Plugin","archived":false,"fork":false,"pushed_at":"2024-07-04T14:51:37.000Z","size":477,"stargazers_count":73,"open_issues_count":2,"forks_count":134,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-03T04:16:52.604Z","etag":null,"topics":["android","cordova","hacktoberfest","ios","java","javascript","library","mobile","nodejs","objective-c"],"latest_commit_sha":null,"homepage":"https://cordova.apache.org/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apache.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-06-22T07:00:15.000Z","updated_at":"2024-07-04T14:50:41.000Z","dependencies_parsed_at":"2023-01-13T15:09:41.049Z","dependency_job_id":"fbe1d2e9-7d77-40a3-9cbc-430c7df2399a","html_url":"https://github.com/apache/cordova-plugin-device-motion","commit_stats":{"total_commits":255,"total_committers":58,"mean_commits":4.396551724137931,"dds":0.7176470588235294,"last_synced_commit":"eaf7da272724e136b33e78b26a811c30f6ddfb8d"},"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-plugin-device-motion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-plugin-device-motion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-plugin-device-motion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-plugin-device-motion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apache","download_url":"https://codeload.github.com/apache/cordova-plugin-device-motion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247157995,"owners_count":20893359,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","cordova","hacktoberfest","ios","java","javascript","library","mobile","nodejs","objective-c"],"created_at":"2024-09-24T14:15:58.123Z","updated_at":"2025-04-04T11:17:00.223Z","avatar_url":"https://github.com/apache.png","language":"JavaScript","readme":"---\ntitle: Device Motion\ndescription: Access accelerometer data.\n---\n\u003c!---\n# license: Licensed to the Apache Software Foundation (ASF) under one\n#         or more contributor license agreements.  See the NOTICE file\n#         distributed with this work for additional information\n#         regarding copyright ownership.  The ASF licenses this file\n#         to you under the Apache License, Version 2.0 (the\n#         \"License\"); you may not use this file except in compliance\n#         with the License.  You may obtain a copy of the License at\n#\n#           http://www.apache.org/licenses/LICENSE-2.0\n#\n#         Unless required by applicable law or agreed to in writing,\n#         software distributed under the License is distributed on an\n#         \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n#         KIND, either express or implied.  See the License for the\n#         specific language governing permissions and limitations\n#         under the License.\n--\u003e\n\n# cordova-plugin-device-motion\n\n[![Android Testsuite](https://github.com/apache/cordova-plugin-device-motion/actions/workflows/android.yml/badge.svg)](https://github.com/apache/cordova-plugin-device-motion/actions/workflows/android.yml) [![Chrome Testsuite](https://github.com/apache/cordova-plugin-device-motion/actions/workflows/chrome.yml/badge.svg)](https://github.com/apache/cordova-plugin-device-motion/actions/workflows/chrome.yml) [![iOS Testsuite](https://github.com/apache/cordova-plugin-device-motion/actions/workflows/ios.yml/badge.svg)](https://github.com/apache/cordova-plugin-device-motion/actions/workflows/ios.yml) [![Lint Test](https://github.com/apache/cordova-plugin-device-motion/actions/workflows/lint.yml/badge.svg)](https://github.com/apache/cordova-plugin-device-motion/actions/workflows/lint.yml)\n\n# Usage Notice\n\nWith the [W3C Device Orientation API](https://www.w3.org/TR/orientation-event/), Android, iOS, and Windows devices may not need this plugin anymore.\n\nHowever, 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.\n\n----\n\n\n## Description\n\nThis plugin provides access to the device's accelerometer. The accelerometer is\na motion sensor that detects the change (_delta_) in movement relative to the\ncurrent device orientation, in three dimensions along the _x_, _y_, and _z_\naxis.\n\nAccess is via a global `navigator.accelerometer` object.\n\nAlthough the object is attached to the global scoped `navigator`, it is not available until after the `deviceready` event.\n\n    document.addEventListener(\"deviceready\", onDeviceReady, false);\n    function onDeviceReady() {\n        console.log(navigator.accelerometer);\n    }\n\nReport issues with this plugin on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Device%20Motion%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)\n\n## Installation\n\n    cordova plugin add cordova-plugin-device-motion\n\n## Supported Platforms\n\n- Android\n- Browser\n- iOS\n- Windows\n\n## Methods\n\n- navigator.accelerometer.getCurrentAcceleration\n- navigator.accelerometer.watchAcceleration\n- navigator.accelerometer.clearWatch\n\n## Objects\n\n- Acceleration\n\n## navigator.accelerometer.getCurrentAcceleration\n\nGet the current acceleration along the _x_, _y_, and _z_ axes.\n\nThese acceleration values are returned to the `accelerometerSuccess`\ncallback function.\n\n    navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);\n\n\n### Example\n\n    function onSuccess(acceleration) {\n        alert('Acceleration X: ' + acceleration.x + '\\n' +\n              'Acceleration Y: ' + acceleration.y + '\\n' +\n              'Acceleration Z: ' + acceleration.z + '\\n' +\n              'Timestamp: '      + acceleration.timestamp + '\\n');\n    }\n\n    function onError() {\n        alert('onError!');\n    }\n\n    navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);\n\n### Browser Quirks\n\nValues for X, Y, Z motion are all randomly generated in order to simulate the accelerometer.\n\n### Android Quirks\n\nThe 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](http://developer.android.com/guide/topics/sensors/sensors_overview.html#sensors-monitor).\n\n\n### iOS Quirks\n\n- iOS doesn't recognize the concept of getting the current acceleration at any given point.\n\n- You must watch the acceleration and capture the data at given time intervals.\n\n- Thus, the `getCurrentAcceleration` function yields the last value reported from a `watchAccelerometer` call.\n\n## navigator.accelerometer.watchAcceleration\n\nRetrieves the device's current `Acceleration` at a regular interval, executing\nthe `accelerometerSuccess` callback function each time. Specify the interval in\nmilliseconds via the `acceleratorOptions` object's `frequency` parameter.\n\nThe returned watch ID references the accelerometer's watch interval,\nand can be used with `navigator.accelerometer.clearWatch` to stop watching the\naccelerometer.\n\n    var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,\n                                                           accelerometerError,\n                                                           accelerometerOptions);\n\n- __accelerometerOptions__: An object with the following optional keys:\n  - __frequency__: requested frequency of calls to accelerometerSuccess with acceleration data in Milliseconds. _(Number)_ (Default: 10000)\n\n\n###  Example\n\n    function onSuccess(acceleration) {\n        alert('Acceleration X: ' + acceleration.x + '\\n' +\n              'Acceleration Y: ' + acceleration.y + '\\n' +\n              'Acceleration Z: ' + acceleration.z + '\\n' +\n              'Timestamp: '      + acceleration.timestamp + '\\n');\n    }\n\n    function onError() {\n        alert('onError!');\n    }\n\n    var options = { frequency: 3000 };  // Update every 3 seconds\n\n    var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);\n\n### iOS Quirks\n\nThe API calls the success callback function at the interval requested,\nbut restricts the range of requests to the device between 40ms and\n1000ms. For example, if you request an interval of 3 seconds,\n(3000ms), the API requests data from the device every 1 second, but\nonly executes the success callback every 3 seconds.\n\n## navigator.accelerometer.clearWatch\n\nStop watching the `Acceleration` referenced by the `watchID` parameter.\n\n    navigator.accelerometer.clearWatch(watchID);\n\n- __watchID__: The ID returned by `navigator.accelerometer.watchAcceleration`.\n\n###  Example\n\n    var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);\n\n    // ... later on ...\n\n    navigator.accelerometer.clearWatch(watchID);\n\n## Acceleration\n\nContains `Accelerometer` data captured at a specific point in time.\nAcceleration values include the effect of gravity (9.81 m/s^2), so that when a\ndevice lies flat and facing up, _x_, _y_, and _z_ values returned should be\n`0`, `0`, and `9.81`.\n\n### Properties\n\n- __x__:  Amount of acceleration on the x-axis. (in m/s^2) _(Number)_\n- __y__:  Amount of acceleration on the y-axis. (in m/s^2) _(Number)_\n- __z__:  Amount of acceleration on the z-axis. (in m/s^2) _(Number)_\n- __timestamp__: Creation timestamp in milliseconds. _(DOMTimeStamp)_\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fcordova-plugin-device-motion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapache%2Fcordova-plugin-device-motion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fcordova-plugin-device-motion/lists"}