[英]Firebase SDK for Swift, Not automatically sending events
I've created an Swift App using SwiftUI lifecycle.我使用 SwiftUI 生命周期创建了一个 Swift 应用程序。
I followed the instruction here我按照这里的说明操作
I installed Firebase SDK using Xcode not CocoaPods.我使用 Xcode 而不是 CocoaPods 安装了 Firebase SDK。
What I wanted is that Firebase send an event whenever a user open a "View".我想要的是 Firebase 每当用户打开“视图”时发送一个事件。
Here is my code snippet.这是我的代码片段。
import SwiftUI
import UIKit
import Firebase
@main
struct my_App: App {
init() {
FirebaseApp.configure()
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
and another file for a view.和另一个视图文件。
import SwiftUI
import FirebaseAnalytics
struct ContentView: View {
var body: some View {
NavigationView {
Text("Hello World")
}
}
}
However, When I add Analytics.logEvent("CustomView", parameters: nil)
to ContentView.但是,当我将Analytics.logEvent("CustomView", parameters: nil)
添加到 ContentView 时。
Firebase sends the event data. Firebase 发送事件数据。
Is there an argument to set to automatically send event whenever a View is appeared?是否有一个参数可以设置为在出现 View 时自动发送事件?
Thanks谢谢
Add the FirebaseAnalyticsSwift target to the project.将 FirebaseAnalyticsSwift 目标添加到项目中。 (See https://www.kiloloco.com/articles/010-add-package-product-xcode/ ) and add import FirebaseAnalyticsSwift
to the source. (参见https://www.kiloloco.com/articles/010-add-package-product-xcode/ )并将import FirebaseAnalyticsSwift
添加到源中。
See the implementation at https://github.com/firebase/firebase-ios-sdk/blob/master/FirebaseAnalyticsSwift/Sources/Analytics%2BSwiftUI.swift .请参阅https://github.com/firebase/firebase-ios-sdk/blob/master/FirebaseAnalyticsSwift/Sources/Analytics%2BSwiftUI.swift中的实施。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.