Answers By Crashlytics - adding custom event

試著忘記壹切 提交于 2019-12-10 17:08:04

问题


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.

I am trying to add a custom event, by using the following line of code in my 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.

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.

Thanks

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

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

回答1:


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.



来源:https://stackoverflow.com/questions/35384316/answers-by-crashlytics-adding-custom-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!