Fabric.io Crashlytics和Answers初始化

noo*_*obs 5 ios crashlytics twitter-fabric

我已将Crashlytics包含在我的应用中.我做了注册向导并[Fabric with:@[[Crashlytics class]]];按照我的指示初始化了CrashlyticsAppDelegate.m

我需要做什么来初始化答案以及在我的应用程序中这样做的最佳位置?我现在只想要基本的初始化.

Vin*_*ary 2

对于基本指标,您需要包含插件中的 Answers Kit 才能使用 Answers!


用于使用 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
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述在此输入图像描述


对于跟踪关键指标

答案可以跟踪应用程序中的关键指标,例如撰写的推文、播放的歌曲和观看的视频。接下来,将代码复制到您的项目中以检测应用程序的关键指标之一。

视图控制器.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
Run Code Online (Sandbox Code Playgroud)

初始化成功后,答案选项卡将显示应用程序和关键指标 在此输入图像描述

  • @noobsmcgoobs 对于两者,你都可以像这样使用 -&gt; [Fabric with:@[[Crashlytics class],[Answers class]]]; (3认同)