gpt4 book ai didi

swift - 在哪里放置 Firebase 性能跟踪

转载 作者:行者123 更新时间:2023-11-28 15:02:24 25 4
gpt4 key购买 nike

我正在尝试确定放置 firebase 性能跟踪的最佳位置。我想看看我的应用提取数据需要多长时间。

在我的 VC 中我有以下内容

  func pullAllUsersCards() {
// 1 Start Here?
FirebaseUtility.shared.getCards { (cards, errMessage) in
if let theCards = cards {
if theCards.count < 1 {
if let addVC = self.storyboard?.instantiateViewController(withIdentifier: StoryboardKeys.addCardViewControllerStoryboardID) as? AddCardViewController {
let addNavigation = UINavigationController(rootViewController: addVC)
if UIDevice.current.userInterfaceIdiom == .pad {
self.splitViewController?.present(addNavigation, animated: true, completion: nil)
} else {
self.present(addNavigation, animated: true, completion: nil)
}
}
} else {
// 2 Start Here?
MBProgressHUD.showAdded(to: self.view, animated: true)
self.cardArray = theCards
self.tableView.reloadData()
MBProgressHUD.hide(for: self.view, animated: true)
}
}
}
}

最初我想将跟踪放在 getCards 方法所在的单例类 FirebaseUtility 上。

  func getCards(completion: @escaping (_ cards: [Card]?, _ errorMessage: String?) -> Void) {
// let testTrace = Performance.startTrace(name: "Test")
guard let userID = user?.uid else {
let error = "Unknown error occured! User is not logged in."
completion(nil, error)
return
}

let userCardRef = ref.child(FirebaseKeys.newCards).child(userID)
userCardRef.observe(.value, with: { (snapshot) in // changed from Single Event
let enumerator = snapshot.children
var cards = [Card]()

while let cardSnapshot = enumerator.nextObject() as? DataSnapshot {
if let cardDict = cardSnapshot.value as? [String : Any] {
let card = Card(id: cardSnapshot.key, cardDict: cardDict)
cards.append(card)
}
}
completion(cards, nil)
})
// testTrace?.stop()
}

然而,当我尝试在那里使用它时,我收到一条错误消息,提示 Firebase Performance 目前不支持扩展

最佳答案

您是否在 App Extension(例如 Watch、keyboard、today 等)的上下文中使用 Firebase Performance?该消息由 FirebasePerformance.h 文件中的这一行触发:

NS_EXTENSION_UNAVAILABLE(“FirebasePerformance 目前不支持应用程序扩展。”)

Firebase Performance 目前仅支持 iOS 上的普通应用程序。

关于swift - 在哪里放置 Firebase 性能跟踪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48773738/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com