---
title: "User Feedback"
description: "Learn how to enable User Feedback in your Cocoa app."
url: https://docs.sentry.io/platforms/apple/guides/ios/user-feedback/
---

# Set Up User Feedback | Sentry for iOS

The User Feedback feature allows you to collect user feedback from anywhere inside your application at any time, without needing an error event to occur first.

If you're using a self-hosted Sentry instance, you'll need to be on version 24.4.2 or higher in order to use the full functionality of the User Feedback feature. Lower versions may have limited functionality.

## [User Feedback Widget](https://docs.sentry.io/platforms/apple/guides/ios/user-feedback.md#user-feedback-widget)

The User Feedback widget allows users to submit feedback from anywhere inside your application.

### [Pre-requisites](https://docs.sentry.io/platforms/apple/guides/ios/user-feedback.md#pre-requisites)

Ensure that your project is set up with Sentry and that you have added the Sentry Cocoa SDK to your project.

### [Installation](https://docs.sentry.io/platforms/apple/guides/ios/user-feedback.md#installation)

1. Install the Sentry Cocoa SDK using Swift Package Manager or by manually adding the [pre-built XCFramework from GitHub releases](https://github.com/getsentry/sentry-cocoa/releases).
2. Ensure you are using version 8.46.0 or above of the SDK to access the latest features.

### [Set Up](https://docs.sentry.io/platforms/apple/guides/ios/user-feedback.md#set-up)

To start using the User Feedback widget in your Cocoa application, provide a feedback configuration in your `SentryOptions` when starting the SDK:

```swift
 SentrySDK.start { options in
     options.configureUserFeedback = { config in
          config.onSubmitSuccess = { data in
               print("Feedback submitted successfully: \(data)")
          }
          config.onSubmitError = { error in
               print("Failed to submit feedback: \(error)")
          }
     }
 }
```

This setup will insert the widget into your app's view hierarchy. By default, it appears in the bottom trailing corner of the screen, but you can fully customize its appearance and behavior.

#### [SwiftUI](https://docs.sentry.io/platforms/apple/guides/ios/user-feedback.md#swiftui)

SwiftUI apps don’t currently support automatic widget injection when the SDK starts. Several options exist to display the feedback form:

##### [Use your own button](https://docs.sentry.io/platforms/apple/guides/ios/user-feedback.md#use-your-own-button)

Add a `UIButton` to your app, then provide the reference to the feedback configuration in the SDK start options:

```swift
import Sentry
import SwiftUI
import UIKit

@main
struct SwiftUIApp: App {
    // a button displayed somewhere in your app
    public let feedbackButton = {
        let button = UIButton(type: .custom)
        button.setTitle("BYOB Feedback", for: .normal)
        return button
    }()

    init() {
        // start the SentrySDK as usual, as early as possible in your app's launch sequence
        SentrySDK.start { options in
            options.configureUserFeedback { config in
                config.customButton = feedbackButton
            }

            // your other SDK options
        }
    }
}
```

##### [Manually display the widget from a connected `UIWindowSceneDelegate`](https://docs.sentry.io/platforms/apple/guides/ios/user-feedback.md#manually-display-the-widget-from-a-connected-uiwindowscenedelegate)

You must set up a `UIApplicationDelegateAdaptor`, connect a `UIScene` to your app, and manually call `SentrySDK.feedback.showWidget()`:

```swift
import Sentry
import SwiftUI

@main
struct SwiftUIApp: App {
    @UIApplicationDelegateAdaptor private var appDelegate: MyAppDelegate

    init() {
        // start the SentrySDK as usual, as early as possible in your app's launch sequence
        SentrySDK.start { options in
            options.configureUserFeedback { config in
                // configure user feedback and any other SDK options
            }
        }
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

class MyAppDelegate: NSObject, UIApplicationDelegate, ObservableObject {
    func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
        let configuration = UISceneConfiguration(
            name: nil,
            sessionRole: connectingSceneSession.role)
        if connectingSceneSession.role == .windowApplication {
            configuration.delegateClass = MySceneDelegate.self
        }
        return configuration
    }
}

class MySceneDelegate: NSObject, UIWindowSceneDelegate, ObservableObject {
    var initializedSentry = false
    func sceneDidBecomeActive(_ scene: UIScene) {
        guard !initializedSentry else { return }

        // display the feedback widget
        SentrySDK.feedback.showWidget()

        initializedSentry = true
    }
}
```

##### [Manually display the widget from an `onAppear` view modifier](https://docs.sentry.io/platforms/apple/guides/ios/user-feedback.md#manually-display-the-widget-from-an-onappear-view-modifier)

You can manually call `SentrySDK.feedback.showWidget()` from an `onAppear` view modifier. Ideally, you should call this from the root view of your app, so that the widget is displayed as soon as the app is launched and only called once.

```swift
import Sentry
import SwiftUI

@main
struct SwiftUIApp: App {

    var body: some Scene {
        WindowGroup {
            ContentView()
                .onAppear {
                    SentrySDK.feedback.showWidget()
                }
        }
    }
}
```

### [Shake to Report](https://docs.sentry.io/platforms/apple/guides/ios/user-feedback.md#shake-to-report)

You can enable shake-to-report so that shaking the device opens the User Feedback form. This is only supported on iOS.

```swift
SentrySDK.start { options in
    options.configureUserFeedback { config in
        config.useShakeGesture = true
    }
}
```

### [Session Replay](https://docs.sentry.io/platforms/apple/guides/ios/user-feedback.md#session-replay)

The User Feedback widget integrates seamlessly with Session Replay. When the widget is opened, the Replay SDK buffers up to 30 seconds of the user's session. If feedback is submitted, this replay is sent along with the feedback, allowing you to view both the feedback and the user's actions leading up to the feedback submission.

### [User Feedback API](https://docs.sentry.io/platforms/apple/guides/ios/user-feedback.md#user-feedback-api)

The User Feedback API allows you to collect user feedback while using your own UI components. You can submit feedback directly using the `SentrySDK.capture(feedback:)` method:

```swift
SentrySDK.capture(feedback: .init(
    message: "I encountered a bug while using the app.",
    name: "John Doe",
    email: "john.doe@example.com",
    source: .custom,
    screenshot: somePngImageData // optional
))
```

## Pages in this section

- [Configure User Feedback](https://docs.sentry.io/platforms/apple/guides/ios/user-feedback/configuration.md)
