CrashReporterAC
描述
错误报告包含设备日志、堆栈跟踪和其他诊断信息,以帮助您找到并修复应用程序中的错误。还应包括有助于您重现问题的用户反馈。不幸的是,这并非 Microsoft' AppCenter for macOS 实现的一部分。然而,存在允许您将文本附件与每个崩溃一起发送的 API。CrashReporterAC 会请求用户反馈,并带有崩溃详情提交给 AppCenter。
截图
示例
要运行示例项目,请克隆仓库,然后从 Example 目录运行 pod install
需求
- macOS 10.10
- Microsoft AppCenter
安装
CrashReporterAC 通过 CocoaPods 可用。要安装它,只需在 Podfile 中添加以下行
pod 'CrashReporterAC'
将这些添加到您的 AppDelegate 中
private let crashReporterAC = CrashReporterAC(helpURL: URL(string: "https://example.com/privacy/#app-center"))
确保在调用 MSAppCenter.start()
之前添加以下内容,通常在 applicationDidFinishLaunching(_:)
中
MSCrashes.setDelegate(self)
let crashReporterAC = CrashReporterAC(helpURL: URL(string: "https://example.com/privacy/#app-center"))
MSCrashes.setUserConfirmationHandler(crashReporterAC.userConfirmationHandler)
还需实现代理
// MARK: - MSCrashesDelegate
func attachments(with crashes: MSCrashes, for errorReport: MSErrorReport) -> [MSErrorAttachmentLog] {
guard crashReporterAC.crashUserProvidedDescription != nil else {
return []
}
let attachment1 = MSErrorAttachmentLog.attachment(withText: crashReporterAC.crashUserProvidedDescription!, filename: "UserProvidedDescription.txt")
return [attachment1!
}
func crashes(_ crashes: MSCrashes!, didFailSending errorReport: MSErrorReport!, withError error: Error!) {
crashReporterAC.crashUserProvidedDescription = nil
}
func crashes(_ crashes: MSCrashes!, didSucceedSending errorReport: MSErrorReport!) {
crashReporterAC.crashUserProvidedDescription = nil
}
作者
Daniel Witt,[email protected]
本地化
- Massimiliano Picchi(意大利语)
- Ange Lefrère(法语)
- Daniel Witt(德语)
许可
CrashReporterAC 在 MIT 许可证下提供。有关更多信息,请参阅 LICENSE 文件。