Skip to content

Modules.CoreMotion.Magnetometer

Allows Titanium client applications to access CoreMotion's Magnetometer APIs.

Extends: Titanium.Proxy · Since: 5.2.0 · Platforms: iphone, ipad

Methods #

getMagnetometerData #

Returns the latest sample of magnetometer data.

An app that is receiving magnetometer data after calling
Modules.CoreMotion.Magnetometer.startMagnetometerUpdates with no callback, needs to periodically
check the value returned by this method and process the magnetometer data.

Returns: CoreMotionMagnetometerData

isMagnetometerActive #

Returns a Boolean indicating whether magnetometer updates are currently happening.

Returns: Boolean

isMagnetometerAvailable #

Returns a Boolean indicating whether a magnetometer is available on the device.

Returns: Boolean

setMagnetometerUpdateInterval #

The interval in milliseconds, for providing magnetometer updates to the callback.

Parameters:
NameTypeSummaryOptional
intervalNumberThe interval in millisecondsNo

startMagnetometerUpdates #

Starts magnetometer updates.

If a callback is passed to this method, it will be called whenever there is an update.
The frequency of these updates can be controlled using the
Modules.CoreMotion.Magnetometer.setMagnetometerUpdateInterval method. If no callback is passed,
the magnetometer data can be accessed using the Modules.CoreMotion.Magnetometer.getMagnetometerData
method. You must call Modules.CoreMotion.Magnetometer.stopMagnetometerUpdates when you no
longer want your app to process magnetometer updates.

Parameters:
NameTypeSummaryOptional
callbackCallback<CoreMotionMagnetometerDataWithSuccess>The method to be called when there is an update.Yes

stopMagnetometerUpdates #

Stops magnetometer updates.

Titanium SDK Documentation