Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fabric.io Crashlytics and Answers initialization

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.

like image 535
noobsmcgoobs Avatar asked Oct 30 '22 15:10

noobsmcgoobs


1 Answers

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

enter image description hereenter image description here


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 enter image description here

like image 157
Vineet Choudhary Avatar answered Nov 13 '22 19:11

Vineet Choudhary