I am trying to incorporate MetricKit into an empty application created for MacOS objective-C and I'm wondering how to use MetricKit. I'm following this tutorial https://nshipster.com/metrickit/. So far I have:
#import <MetricKit/MetricKit.h>
#import "AppDelegate.h"
@interface AppDelegate ()
@property (strong) IBOutlet NSWindow *window;
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
[MXMetricManager.sharedManager addSubscriber:self];
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
// Insert code here to tear down your application
[MXMetricManager.sharedManager removeSubscriber:self];
}
- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app {
return YES;
}
@end
But I do not know if this is correct and I also do not know how to implement the didReceive method.
- How do I use MetricKit in objective-c?
- How do I test it? Reports are supposed to be sent every 24hrs, so how do I make the application receive a report?
You need to "conform to the protocol" of MXMetricManagerSubscriber.
Then, add the didReceiveMetricPayloads function.
To test, run your app on a real iOS device. Then, from the Xcode Debug menu, select "Simulate MetricKit Payloads"