Crash Reporting User Consent
This page explains the usage of user consent for iOS crash reports and the needed APIs to implement it.
CrashReporting.onWillSendCrashReportHandler = { crashType, completionHandler in
let crashTypeAsString: String
switch (crashType) {
case .crash:
crashTypeAsString = "Fatal Crash"
case .forceRestart:
crashTypeAsString = "User termination Crash"
case .OOM:
crashTypeAsString = "OOM Crash"
@unknown default:
fatalError()
}
let message = "Are You Sure Want to send Crash! for crash type: \(crashTypeAsString)"
let alert = UIAlertController(title: "Crash Consent", message: message, preferredStyle: .alert)
let yesButton = UIAlertAction(title: "Yes", style: .default, handler: { _ in
completionHandler?(.accept);
})
alert.addAction(yesButton)
let noButton = UIAlertAction(title: "No", style: .default, handler: { _ in
completionHandler?(.reject);
})
alert.addAction(noButton)
let rootViewController = UIApplication.shared.keyWindow?.rootViewController
rootViewController?.present(alert, animated: true)
}Last updated