> For the complete documentation index, see [llms.txt](https://docs.luciq.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.luciq.ai/ios/setup-luciq-for-ios/setup-crash-reporting/crash-reporting-user-consent.md).

# 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.

Suppose you want your users' confirmation before sending a crash report to Luciq. In that case, the Luciq SDK exposes a callback awaiting each user's confirmation before sending any crash/error data to Luciq.

This callback function instructs Luciq to await user confirmation before sending crash reports. It is designed to enhance end-user privacy and control by allowing them to approve or decline the submission of crash reports, ensuring a more transparent and user-centric experience.

This callback applies to fatal errors (crashes) and out-of-memory (OOM) reports, force restarts, and excludes app hangs and non-fatal errors.

If no response is received within a 2-minute window, the callback triggers a timeout mechanism, preventing the automatic crash report sending.

**Example Usage**

{% tabs %}
{% tab title="Swift" %}
{% code overflow="wrap" %}

```swift
 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)

        }
```

{% endcode %}
{% endtab %}

{% tab title="Objective-C" %}
{% code overflow="wrap" %}

```objectivec
LCQCrashReporting.onWillSendCrashReportHandler = ^(LCQCrashType crashType, LCQCrashReportConsentReplyHandler completionHandler) {

        NSString *crashTypeAsString;

        switch (crashType) {

            case LCQCrashTypeCrash:

                crashTypeAsString = @"Fatal Crash";

                break;

            case LCQCrashTypeForceRestart:

                crashTypeAsString = @"User termination Crash";

                break;

            case LCQCrashTypeOOM:

                crashTypeAsString = @"OOM Crash";

                break;

        }

        NSString *message = [NSString stringWithFormat:@"Are You Sure Want to send Crash! for crash type: %@", crashTypeAsString];

        UIAlertController * alert = [UIAlertController

                                     alertControllerWithTitle:@"Crash Consent"

                                     message:message

                                     preferredStyle:UIAlertControllerStyleAlert];

        UIAlertAction* yesButton = [UIAlertAction

                                    actionWithTitle:@"Yes"

                                    style:UIAlertActionStyleDefault

                                    handler:^(UIAlertAction * action) {

            completionHandler(LCQCrashReportConsentAccept);

        }];

        [alert addAction:yesButton];

        UIAlertAction* noButton = [UIAlertAction

                                   actionWithTitle:@"No"

                                   style:UIAlertActionStyleDefault

                                   handler:^(UIAlertAction * action) {

            completionHandler(LCQCrashReportConsentReject);

        }];

        [alert addAction:noButton];

        UIViewController *rootViewController = [UIApplication.sharedApplication.keyWindow rootViewController];

        [rootViewController presentViewController:alert animated:YES completion:nil];

    };
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.luciq.ai/ios/setup-luciq-for-ios/setup-crash-reporting/crash-reporting-user-consent.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
