答案由Crashlytics - 添加自定义事件

时间:2021-12-07 00:00:25

I have an app using Crashlytics with Answers. Both are working right, and I am seeing events that are built into the framework being tracked.

我有一个使用Crashlytics with Answers的应用程序。两者都正常工作,我看到正在跟踪框架内置的事件。

I am trying to add a custom event, by using the following line of code in my View Controller:

我试图通过在我的View Controller中使用以下代码行添加自定义事件:

Answers.logCustomEventWithName("Flight Complete", customAttributes: nil)

My issue is that the compiler doesn't recognize the Answers object. It just tells me "Use of unresolved identifier "Answers"" Which makes sense because I've never declared it.

我的问题是编译器无法识别Answers对象。它只是告诉我“使用未解析的标识符”答案“”这是有道理的,因为我从来没有声明它。

I am unsure of where or how to create this Answers object, as it is already integrated and working for default events. Does anyone know where I should declare it for use across the app? (AppDelegate?) or what the declaration looks like? They don't show it in the docs.

我不确定在何处或如何创建此Answers对象,因为它已经集成并适用于默认事件。有谁知道我应该在应用程序中声明它在哪里使用? (AppDelegate?)或声明是什么样的?他们没有在文档中显示它。

Thanks

谢谢

UPDATE: Here's what I've tried adding to AppDelegate but still not recognizing "Answers" object...

更新:这是我尝试添加到AppDelegate,但仍然没有识别“答案”对象...

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    Fabric.with([Crashlytics.self, Answers.self])

1 个解决方案

#1


10  

Wanted to close this question since it is now answered from the comments:

想要关闭这个问题,因为它现在从评论中回答:

I failed to call

我没打电话

import Crashlytics

At the top of the view controller like a complete idiot.

在视图控制器的顶部像一个完整的白痴。

Also, I had added

另外,我补充说

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
Fabric.with([Crashlytics.self, Answers.self])

When it is correct as:

如果它是正确的:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
Fabric.with([Crashlytics.self])

Answers is included in the Crashlytics call.

答案包含在Crashlytics电话中。

#1


10  

Wanted to close this question since it is now answered from the comments:

想要关闭这个问题,因为它现在从评论中回答:

I failed to call

我没打电话

import Crashlytics

At the top of the view controller like a complete idiot.

在视图控制器的顶部像一个完整的白痴。

Also, I had added

另外,我补充说

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
Fabric.with([Crashlytics.self, Answers.self])

When it is correct as:

如果它是正确的:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
Fabric.with([Crashlytics.self])

Answers is included in the Crashlytics call.

答案包含在Crashlytics电话中。