Allows Titanium client applications to access Apple's CoreMotion APIs.
The Core Motion module provides access to Apple's CoreMotion APIs. The Core Motion module provides support for monitoring various hardware sensors on iOS devices, such as the accelerometer, gyroscope, and magnetometer. The Core Motion module allows you to access the metrics provided by these sensors.
For instruction and examples of using the Core Motion Module, see the Core Motion Module guide.
This module only works with devices running iOS 7 and later. Not all devices have the same hardware sensors, so all features may not be available for all devices. Be sure to use the API to check the device for the existence of a feature.
You can only test the Core Motion module on a device. The Core Motion API cannot be tested on the iOS simulator.
Some features may require permission to use "Motion Activity". iOS requires the user's approval to use the "Motion Activity" permission. When the application uses the Core Motion API for the first time, iOS prompts the user to either approve or deny access to the Core Motion features of the device. The user can change the permission settings with Settings > Privacy.
Once you have installed the module and added it as a depedency,
use require()
to access it from JavaScript:
var CoreMotion = require("ti.coremotion");
// The `CoreMotion` variable is a reference to the Module object. Use this reference to make
// subsequent calls to the CoreMotion Module API. The following example shows the step counting
// API of `CoreMotion`.
var pedometer = CoreMotion.createPedometer();
// This code checks to see if the device can gather step counting data
if (pedometer.isStepCountingAvailable()) {
// If it can, it starts the step counter and outputs the data to the console
pedometer.startPedometerUpdates(function(e) {
Ti.API.info(JSON.stringify(e));
});
} else {
Ti.API.warn('This device does not support counting steps.');
}
The module ZIP file contains a Core Motion sample applications in example/app.js
.
Describes the same reference frame as ATTITUDE_REFERENCE_FRAME_X_ARBITRARY_Z_VERTICAL except that the magnetometer, when available and calibrated, is used to improve long-term yaw accuracy. Using this constant instead of ATTITUDE_REFERENCE_FRAME_X_ARBITRARY_Z_VERTICAL results in increased CPU usage.
Describes a reference frame in which the Z axis is vertical and the X axis points in an arbitrary direction in the horizontal plane.
Describes a reference frame in which the Z axis is vertical and the X axis points toward magnetic north. Note that using this reference frame may require device movement to calibrate the magnetometer.
Describes a reference frame in which the Z axis is vertical and the X axis points toward true north. Note that using this reference frame may require device movement to calibrate the magnetometer. It also requires the location to be available in order to calculate the difference between magnetic and true north.
The device must move for a sampling of motion data to occur.
The device must move for a sampling of motion data to occur.
An invalid parameter was specified.
An invalid parameter was specified.
The app is not currently authorized to use motion activity support.
The app is not currently authorized to use motion activity support.
Motion activity support is not available on the current device.
Motion activity support is not available on the current device.
The app is missing a required entitlement.
The app is missing a required entitlement.
True north is not available on this device. This usually indicates that the device's location is not yet available.
The accuracy of the magnetic field calibration is high.
The accuracy of the magnetic field calibration is high.
The accuracy of the magnetic field calibration is low.
The accuracy of the magnetic field calibration is low.
The accuracy of the magnetic field calibration is medium.
The accuracy of the magnetic field calibration is medium.
The magnetic field estimate is not calibrated.
The magnetic field estimate is not calibrated.
The name of the API that this proxy corresponds to.
The name of the API that this proxy corresponds to.
The value of this property is the fully qualified name of the API. For example, Button
returns Ti.UI.Button
.
The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.
The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.
If this property is set to a Window or TabGroup, then the corresponding Activity lifecycle event callbacks will also be called on the proxy. Proxies that require the activity lifecycle will need this property set to the appropriate containing Window or TabGroup.
Creates and returns an instance of Modules.CoreMotion.Accelerometer.
Properties to set on a new object, including any defined by Modules.CoreMotion.Accelerometer except those marked not-creation or read-only.
Creates and returns an instance of Modules.CoreMotion.DeviceMotion.
Properties to set on a new object, including any defined by Modules.CoreMotion.DeviceMotion except those marked not-creation or read-only.
Creates and returns an instance of Modules.CoreMotion.Gyroscope.
Properties to set on a new object, including any defined by Modules.CoreMotion.Gyroscope except those marked not-creation or read-only.
Creates and returns an instance of Modules.CoreMotion.Magnetometer.
Properties to set on a new object, including any defined by Modules.CoreMotion.Magnetometer except those marked not-creation or read-only.
Creates and returns an instance of Modules.CoreMotion.MotionActivity.
Properties to set on a new object, including any defined by Modules.CoreMotion.MotionActivity except those marked not-creation or read-only.
Creates and returns an instance of Modules.CoreMotion.Pedometer.
Properties to set on a new object, including any defined by Modules.CoreMotion.Pedometer except those marked not-creation or read-only.
Creates and returns an instance of Modules.CoreMotion.StepCounter.
deprecated
5.2.0 This API was deprecated by Apple in iOS 7 and is only available for backward compatibility
with older versions of this module. It will be removed in the next release. Please use
<Modules.CoreMotion.Pedometer> API instead, which provides the same functionality including
new properties like floorCount
and distance
.
Properties to set on a new object, including any defined by Modules.CoreMotion.StepCounter except those marked not-creation or read-only.
Sets the value of the lifecycleContainer property.
New value for the property.