I'm trying to log screen names in my app but I have like 95% not set in Firebase Analytics.
In onAppear
for a view I do Analytics.setScreenName("screenName", screenClass: "screenName")
Should I do this differently? It seems that Analytics for iOS works in conjunction with UIViewController
s but since this a SwiftUI app and there is no documentation on how to work with that.
Update
This is now possible using the analyticsScreen
view modifier. See the source code
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)))
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With