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


class MXMetricManager : NSObject


The MXMetricManager shared object manages your subscription for receiving on-device daily metrics.

To receive metrics, call add(_:) with an object supporting the didReceive(_:) method of MXMetricManagerSubscriber. The system then sends a report as an array of MXMetricPayload objects at most once per day. The array contains the metrics from the past 24 hours and any previously undelivered daily reports.

class AppDelegate: UIResponder, UIApplicationDelegate, MXMetricManagerSubscriber {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        let shared = MXMetricManager.shared
        return true

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


Getting the Shared Metrics Manager

class var shared: MXMetricManager

An object that returns the shared metrics manager instance.

Subscribing to Reports

func add(MXMetricManagerSubscriber)

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

func remove(MXMetricManagerSubscriber)

Unsubscribes from daily reports of app metrics.

protocol MXMetricManagerSubscriber

A protocol defining a method for receiving a daily metrics report.

Retrieving Previous Reports

var pastPayloads: [MXMetricPayload]

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

Creating Custom Metric Logs

class func makeLogHandle(category: String) -> OSLog

Returns a log handle used for writing custom metric events.


Inherits From

Conforms To

See Also


class MXMetricPayload

An object that encapsulates a daily metrics report.


Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software