---
title: "startMagnetometerUpdates(to:withHandler:)"
framework: coremotion
role: symbol
role_heading: Instance Method
path: "coremotion/cmmotionmanager/startmagnetometerupdates(to:withhandler:)"
---

# startMagnetometerUpdates(to:withHandler:)

Starts magnetometer updates on an operation queue and with a specified handler.

## Declaration

```swift
func startMagnetometerUpdates(to queue: OperationQueue, withHandler handler: @escaping CMMagnetometerHandler)
```

## Parameters

- `queue`: An operation queue provided by the caller. Because the processed events might arrive at a high rate, using the main operation queue is not recommended.
- `handler`: A block that is invoked with each update to handle new magnetometer data. The block must conform to the doc://com.apple.coremotion/documentation/CoreMotion/CMMagnetometerHandler type.

## Discussion

Discussion You must call stopMagnetometerUpdates() when you no longer want your app to process magnetometer updates.

## See Also

### Managing Magnetometer Updates

- [magnetometerUpdateInterval](coremotion/cmmotionmanager/magnetometerupdateinterval.md)
- [startMagnetometerUpdates()](coremotion/cmmotionmanager/startmagnetometerupdates().md)
- [stopMagnetometerUpdates()](coremotion/cmmotionmanager/stopmagnetometerupdates().md)
- [magnetometerData](coremotion/cmmotionmanager/magnetometerdata.md)
- [CMMagnetometerHandler](coremotion/cmmagnetometerhandler.md)
