终于 Crashlytics 添加了所需的功能 3.5.0!!
[CrashlyticsKit recordError:error];
或
Crashlytics.sharedInstance().recordError(error)
参考
/**
*
* 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.
*
* You can also use the -recordError:withAdditionalUserInfo: to include additional context not represented
* by the NSError instance itself.
*
**/
- (void)recordError:(NSError *)error;
- (void)recordError:(NSError *)error withAdditionalUserInfo:(nullable CLS_GENERIC_NSDICTIONARY(NSString *, id) *)userInfo;
https://docs.fabric.io/ios/changelog.html#january-7-2016
历史
这实际上并没有像我预期的那样工作:消息被保存到 Crashlytics 但只有在应用重新启动后才会保存最后一条消息。
到目前为止,这里提到的解决方案都不起作用。无法使用 Crashlytics 在 iOS 中跟踪处理的异常。
您可以使用它来记录任何异常
[[Crashlytics sharedInstance] recordCustomExceptionName:@"HandledException" reason:@"Some reason" frameArray:@[]];
在 Crashlytics 中,您会在崩溃报告中看到它,但类型为 NON-FATALS。
如果不是预期的使用异常,则事件的记录方式与 Android 处理异常的方式相同。
这在版本 3.0.7 中可用。
recordCustomExceptionName:reason:frameArray:
此方法可用于在报告中记录单个异常结构。这在您的代码与 Lua、C# 或 Javascript 等非本地语言交互时特别有用。此调用可能很昂贵,并且只能在进程终止前不久使用。此 API 不打算用于记录 NSException 对象。 Crashlytics 会自动捕获所有可安全报告的 NSException。
https://docs.fabric.io/appledocs/Crashlytics/Classes/Crashlytics.html#//api/name/recordCustomExceptionName:reason:frameArray: