【问题标题】:Fabric.io Crashlytics and Answers initializationFabric.io Crashlytics 和 Answers 初始化
【发布时间】:2015-11-23 02:30:21
【问题描述】:

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

我需要做什么来初始化 Answers 以及在我的应用中这样做的最佳位置是什么?我现在只想要基本的初始化。

【问题讨论】:

    标签: ios crashlytics twitter-fabric


    【解决方案1】:

    对于基本指标,您需要在插件中包含 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
    


    跟踪关键指标

    Answers 可以跟踪您应用中的关键指标,例如撰写的推文、播放的歌曲和观看的视频。 然后将代码复制到您的项目中,以检测您应用的一项关键指标。

    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
    

    初始化成功后,答案选项卡会显示 App 和 Key Metric

    【讨论】:

    • 由于某种原因,第一个“使用 Fabric 初始化答案”没有出现,但在 Crashlytics 中出现了。也许我没看到。
    • @noobsmcgoobs 两者都可以这样使用 -> [Fabric with:@[[Crashlytics class],[Answers class]]];
    • @VineetChoudhary 我收到一条错误消息,提示找不到“Fabric/Fabric.h”文件。我在另一个 SO 问题 (stackoverflow.com/questions/29923807/…) 中看到我需要配置尚未安装的 Teamcity。你使用 Teamcity 吗?知道如何在没有 Teamcity 的情况下解决这个问题吗?
    • @Yossi 我不使用 TeamCity。我将自托管 Jenkins 与 AppBox (getappbox.com) 与 Gitlab 一起使用,但我从未遇到过此类问题。如果它在我的系统中 99% 的时间都可以工作,那么它也可以在 Jenkins 上工作。有时我忘记更新私钥。 :P
    • @VineetChoudhary 谢谢。仍然卡在我的构建中...不知道如何解决它:(
    猜你喜欢
    • 2014-12-19
    • 2018-07-16
    • 2015-05-14
    • 1970-01-01
    • 2020-03-21
    • 2016-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多