如何在SwiftUI应用中记录Firebase Analytics屏幕名称? [英] How to log Firebase Analytics screen name in a SwiftUI app?

查看:68
本文介绍了如何在SwiftUI应用中记录Firebase Analytics屏幕名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的应用中记录屏幕名称,但我希望95%的Firebase Analytics中没有设置.

I'm trying to log screen names in my app but I have like 95% not set in Firebase Analytics.

onAppear 中查看一个视图 Analytics.setScreenName("screenName",screenClass:"screenName")

我该怎么做?看来Google Analytics(分析)iOS版可以与 UIViewController s结合使用,但是由于这是一个SwiftUI应用程序,因此没有有关如何使用它的文档.

Should I do this differently? It seems that Analytics for iOS works in conjunction with UIViewControllers but since this a SwiftUI app and there is no documentation on how to work with that.

推荐答案

我们正在为此寻求更好的解决方案.正如您所提到的,SwiftUI应用程序的视图控制器层次结构的构成方式,并不是完全不容易解决的,但是我们有一些想法.

We are working on a better solution for this. As you mentioned, the way the view controller hierarchy of a SwiftUI app is made up, this is not entirely trivial to solve, but we've got a couple of ideas.

同时,您可能想要尝试一些人在

In the meantime, you might want to try this workaround that some people have suggested on the Github issue:

DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
  Analytics.setScreenName("todo_tab", screenClass: String(describing: type(of: self)))
}

这篇关于如何在SwiftUI应用中记录Firebase Analytics屏幕名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆