简体   繁体   English

Firebase SDK 为 Swift,不自动发送事件

[英]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.

相关问题 在 Firebase 分析控制台 (Swift) 中记录自定义事件 - Logging custom events in the Firebase Analytics console (Swift) Sending Google Analytics Events via API: How to get app_instance_id or client_id from Firebase SDK from web client? - Sending Google Analytics Events via API: How to get app_instance_id or client_id from Firebase SDK from web client? FCM和Swift firebase-sdk版本8.1.0本地化问题 - FCM and Swift firebase-sdk version 8.1.0 localization problem Firebase iOS 的分析——带有预定义事件的自定义参数 (Swift) - Firebase Analytics for iOS — custom parameters with predefined events (Swift) 从 Firebase function 返回更新方法是否满足 promise 要求并自动记录事件? - Will returning an update method from a Firebase function satisfy the promise requirement and automatically log events? Swift Package 未版本化包的管理器问题(例如:firebase-ios-sdk) - Swift Package Manager issues with unversioned Packages (example: firebase-ios-sdk) Firebase 登录事件 - Firebase Log-in events vue和Firebase不发送数据 - Vue and Firebase not sending data Swift Firebase 数据库覆盖 - Swift Firebase database overwriting 使用 Swift 将录音上传到 Firebase - Uploading recording to Firebase with Swift
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM