gpt4 book ai didi

ios - 如何在 iOS 上报告 Firebase 崩溃的非致命异常?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:57:24 24 4
gpt4 key购买 nike

如何使用 Firebase 崩溃报告在 iOS 上报告非致命异常?在 Android 中,我们可以这样做:

 FirebaseCrash.report(new Exception("My first Firebase non-fatal error on Android"));

最佳答案

您现在可以在 Firebase Crashlytics 中记录非致命异常

因此,接受的答案不再正确。可以使用以下 Firebase Crashlytics 方法记录非致命异常:

Crashlytics.crashlytics().record(error: error)

来自 the documentation :

This allows you to record a non-fatal event, described by an NSError object. These events will be grouped and displayed similarly to crashes. Keep in mind that this method can be expensive. Also, the total number of NSErrors that can be recorded during your app's life-cycle is limited by a fixed-size circular buffer. If the buffer is overrun, the oldest data is dropped. Errors are relayed to Crashlytics on a subsequent launch of your application.


示例用法:

let userInfo: [String: String] = [
"deviceId": "someDeviceId",
"localizedDescription": yourException.localizedDescription,
"anotherKey": "anotherValue"
]

let domain = "METHOD: some/domain/that/just/had-an-exception"
let code = 404

let error = NSError(domain: domain, code: code, userInfo: userInfo)

Crashlytics.crashlytics().record(error: error)

domain 是在 Firebase 中使用的一些漂亮的标识符(例如方法 + 请求路径),code 是异常的状态代码(这里是 404),并且userInfo 附加数据被转换为键值对并显示在单个问题的键/日志部分。

注意:记录的错误按 NSError domaincode 分组(与 fatals 不同,后者在 Firebase 中按堆栈跟踪分组)。


Firebase Console > Crashlytics 中的示例输出:

Example output showing non-fatal exceptions in Firebase Crashlytics console

控制台中的问题详情页面(显示 userInfo 键值对):

Example details view of a non-fatal exception issue in the Firebase Crashlytics console (showing userInfo key-value pairs)

关于ios - 如何在 iOS 上报告 Firebase 崩溃的非致命异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43853090/

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