<!--
{
  "availability" : [
    "iOS: 13.0.0 - 27.0.0",
    "iPadOS: 13.0.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0",
    "macOS: 12.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "MetricKit",
  "identifier" : "/documentation/MetricKit/MXMetricManager",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "MetricKit"
    ],
    "preciseIdentifier" : "c:objc(cs)MXMetricManager"
  },
  "title" : "MXMetricManager"
}
-->

# MXMetricManager

The shared object that registers you to receive metrics, creates logs for custom metrics, and gives access to past reports.

```
class MXMetricManager
```

## Overview

The `MXMetricManager` shared object manages your subscription for receiving on-device daily metrics.
It receives daily metric reports when the device your app is installed on is running iOS 13 and later or macOS 26 and later.

MetricKit starts accumulating reports for your app after calling [`shared`](/documentation/MetricKit/MXMetricManager/shared) for the first time. To receive the reports, call [`add(_:)`](/documentation/MetricKit/MXMetricManager/add(_:)) with an object that adopts the [`MXMetricManagerSubscriber`](/documentation/MetricKit/MXMetricManagerSubscriber) protocol. The system delivers metric reports at most once per day per metric source, and diagnostic reports immediately in iOS 15 and later and macOS 12 and later. Some metrics originate from different system sources and arrive in a separate payload, so your app may receive more than one metric payload per day. The reports contain the metrics from the past 24 hours and any previously undelivered daily reports. To pause receiving reports, call [`remove(_:)`](/documentation/MetricKit/MXMetricManager/remove(_:)).

Calls to add a subscriber and to receive reports are safe to use in performance-sensitive code, such as during app launch.

The following example shows a class that subscribes to and receives MetricKit reports.

```swift
class AppMetrics: NSObject, MXMetricManagerSubscriber {
    func receiveReports() {
       let manager = MXMetricManager.shared
       manager.add(self)
    }

    func pauseReports() {
       let manager = MXMetricManager.shared
       manager.remove(self)
    }

    // Receive daily metrics.
    func didReceive(_ payloads: [MXMetricPayload]) {
       // Process metrics.
    }

    // Receive diagnostics immediately when available.
    func didReceive(_ payloads: [MXDiagnosticPayload]) {
       // Process diagnostics.
    }
}
```

> Note: To test MetricKit in your app, run your app on a physical device to receive metric reports and `didReceive(_:)` callbacks.

## Topics

### Getting the shared metrics manager

[`shared`](/documentation/MetricKit/MXMetricManager/shared)

An object that returns the shared metrics manager instance.

### Subscribing to reports

[`add(_:)`](/documentation/MetricKit/MXMetricManager/add(_:))

Registers to receive a daily report of app metrics from the metrics manager.

[`remove(_:)`](/documentation/MetricKit/MXMetricManager/remove(_:))

Unsubscribes from daily reports of app metrics.

### Retrieving previous reports

[`pastPayloads`](/documentation/MetricKit/MXMetricManager/pastPayloads)

Returns an array of the daily metrics reports generated since the last allocation of the shared manager instance.

[`pastDiagnosticPayloads`](/documentation/MetricKit/MXMetricManager/pastDiagnosticPayloads)

The diagnostic reports since the last initialization of the shared manager instance.

### Creating custom metric logs

[`makeLogHandle(category:)`](/documentation/MetricKit/MXMetricManager/makeLogHandle(category:))

Returns a log handle used for writing custom metric events.

### Measuring an extended launch

[`extendLaunchMeasurement(forTaskID:)`](/documentation/MetricKit/MXMetricManager/extendLaunchMeasurement(forTaskID:))

Starts to measure an extended launch task with the given task identifier.

[`finishExtendedLaunchMeasurement(forTaskID:)`](/documentation/MetricKit/MXMetricManager/finishExtendedLaunchMeasurement(forTaskID:))

Signals the end of an extended launch task.

[`MXLaunchTaskID`](/documentation/MetricKit/MXLaunchTaskID)

The task identifier to track launch measurements.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)