# Modules.CoreMotion.Magnetometer

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

Availability
5.2.0

# Methods

# getMagnetometerData

Availability
5.2.0
getMagnetometerData() CoreMotionMagnetometerData

Returns the latest sample of magnetometer data.

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

Returns


# isMagnetometerActive

Availability
5.2.0
isMagnetometerActive() Boolean

Returns a Boolean indicating whether magnetometer updates are currently happening.

Indicates whether startMagnetometerUpdates has been called since <Modules.CoreMotion.stopMagnetometerUpdates>.

Returns

Type
Boolean

# isMagnetometerAvailable

Availability
5.2.0
isMagnetometerAvailable() Boolean

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

Returns

Type
Boolean

# setMagnetometerUpdateInterval

Availability
5.2.0
setMagnetometerUpdateInterval(interval) void

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

Parameters

Name Type Description
interval Number

The interval in milliseconds

Returns

Type
void

# startMagnetometerUpdates

Availability
5.2.0
startMagnetometerUpdates([callback]) void

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 setMagnetometerUpdateInterval method. If no callback is passed, the magnetometer data can be accessed using the getMagnetometerData method. You must call stopMagnetometerUpdates when you no longer want your app to process magnetometer updates.

Parameters

Name Type Description
callback Callback<CoreMotionMagnetometerDataWithSuccess>

The method to be called when there is an update.

Returns

Type
void

# stopMagnetometerUpdates

Availability
5.2.0
stopMagnetometerUpdates() void

Stops magnetometer updates.

Returns

Type
void