The object that registers you to receive metrics, creates logs for custom metrics, and gives access to past reports.
SDKs
- iOS 13.0+
- Mac Catalyst 13.0+
Framework
- Metric
Kit
Declaration
class MXMetricManager : NSObject
Overview
The MXMetric
shared object manages your subscription for receiving on-device daily metrics.
To receive metrics, call add(_:)
with an object supporting the did
method of MXMetric
. The system then sends a report as an array of MXMetric
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
shared.add(self)
return true
}
// Receive daily metrics
func didReceive(_ payloads: [MXMetricPayload]) {
// Process metrics
}
...
}