I have included Crashlytics into my app. I did the signup wizard and initialized Crashlytics as instructed like so [Fabric with:@[[Crashlytics class]]];
in my AppDelegate.m
What do I need to do to initialize Answers and what the best place to do so in my app? I just want the basic initialization for right now.
For basic metrics, you need to include the Answers Kit from your plugin to use Answers!
For Initialize Answers with Fabric
//AppDelegate.m
#import "AppDelegate.h"
#import <Fabric/Fabric.h>
#import <Answers/Answers.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[Fabric with:@[[Answers class]]];
return YES;
}
@end
For Track Key Metric
Answers can track key metrics in your app like tweets composed, songs played, and videos watched. Follow along by copying code into your project to instrument one of your app's key metric.
ViewController.m
#import "ViewController.h"
#import <Answers/Answers.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"Trigger Key Metric" forState:UIControlStateNormal];
[button addTarget:self action:@selector(anImportantUserAction) forControlEvents:UIControlEventTouchUpInside];
[button sizeToFit];
button.center = self.view.center;
[self.view addSubview:button];
}
- (void)anImportantUserAction {
// TODO: Move this method and customize the name and parameters to track your key metrics
// Use your own string attributes to track common values over time
// Use your own number attributes to track median value over time
[Answers logCustomEventWithName:@"Video Played" customAttributes:@{@"Category":@"Comedy",
@"Length":@350}];
}
@end
Once you initialise successfully, answer tab show you App and Key Metric
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With