Crash Reporting User Consent
Ask your iOS users to confirm before a crash report leaves the device, using the Luciq callback that holds crash data until consent is given.
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