ios - Fabric.io Crashlytics 和 Answers 初始化

标签 ios crashlytics twitter-fabric

我已将 Crashlytics 添加到我的应用程序中。我在我的 AppDelegate.m

中执行了注册向导并按照指示初始化了 Crashlytics

我需要做什么来初始化 Answers 以及在我的应用程序中执行此操作的最佳位置是什么?我现在只想要基本的初始化。

最佳答案

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

enter image description here enter image description here


对于跟踪关键指标

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

关于ios - Fabric.io Crashlytics 和 Answers 初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33862885/

相关文章:

ios - 在 iOS 上从 PhoneGap 打开位智应用程序的链接

ios - 按用户名对 PFObject 数组进行排序

ios - Crashlytics 套件 xcode 缺少套件信息

android-studio - 无法使用 Gradle 插件 0.14.0 和 Android Studio 0.9.0 获取只写属性 'runProguard' 的值

ios - 单击另一个 UITextView 时结束编辑

Firebase 中的 iOS Crashlytics 在 Swift 4.1 中不起作用

android - Crashlytics NDK 多 androidNdkOut 路径支持

ios - 我需要嵌入 Crashlytics/Fabric 框架吗?

ios - 将 Fabric/Crashlytics 添加到新项目但不上传 dSYM

ios - 使用自动布局以编程方式创建 View 层次结构