代码之家  ›  专栏  ›  技术社区  ›  Fattie

firebase分析能在xcode中的模拟器中工作吗?

  •  2
  • Fattie  · 技术社区  · 6 年前

    在iOS应用程序中

    enter image description here

    我确保没有plist“失败”条目,然后我有分析事件,比如

     Analytics.logEvent("touchedButton", parameters: nil)
    

    事实上,如果我只是在Xcode模拟器中运行应用程序这些事件是否报告给Firebase Analytics并显示?

    或者如果你用iPhone来做?

    或者只有当它是一个经过测试的实际构建时它才能工作吗?

    令人惊讶的是,我在任何地方都找不到这些信息。

    这些自定义事件是否正是在这里显示的:

    enter image description here

    1 回复  |  直到 6 年前
        1
  •  3
  •   SpaceDust__    6 年前

    是的,模拟器或设备都能工作。

    如果你还没有读过,请阅读他们的入门教程,它涵盖了大部分内容 https://firebase.google.com/docs/analytics/ios/start

    几点

    1. 确保在配置firestore设置时启用分析

    AnalyticsConfiguration.shared().setAnalyticsCollectionEnabled(true)

    我在AppDelegate中完成所有这些初始设置

    有点像

    //init Firebase
            FirebaseConfiguration.shared.setLoggerLevel(.min)
            FirebaseApp.configure()
            Fabric.with([Crashlytics.self])
            let _ = FirebaseConfig.sharedInstance // This is a custom singelton class where I enable the analytics
    
    1. 在目标的方案设置中,需要添加 -FIRAnalyticsDebugEnabled

    enter image description here

    如你所见,我也有一个禁用选项,有时分析变得疯狂和垃圾邮件的控制台,所以我想禁用它。 -FIRDebugDisabled

    1. 除非指定事件是自定义事件,否则分析将对事件进行群集。

    例如,我使用以下内容来标记viewcontroller名称

        func logEvent(eventTitle:String , eventContent:String)
    {
        Analytics.logEvent(AnalyticsEventSelectContent, parameters: [
            AnalyticsParameterItemID: "AppName-\(eventTitle)" as NSObject,
            AnalyticsParameterItemName: eventTitle as NSObject,
            AnalyticsParameterContentType: eventContent as NSObject
            ])
    }
    

    但在火库里这些都聚集在 select_content 因为我用了 AnalyticsEventSelectContent 创建日志时的键。

    在主事件屏幕下, 选择内容 我的视图控制器记录了上述功能 enter image description here

    4.firestoreconsole中有一个特定的debugview与设备一起工作,只要设置 -已启用FiranalyticDebugEnabled 在这个计划中是正确的。

    enter image description here

    1. firestore控制台的event部分有明显的延迟,我不知道为什么会发生这种情况,但有时会延迟15-30分钟。还没研究过这个问题,我真的不介意。