Pulse FlightRecorder Docs
  • SDK Documentation
    • Pulse Labs FlightRecorder Documentation
      • iOS
        • Overview
        • Install the SDK
        • Get your API Key
        • SDK Configuration
          • Swift + SwiftUI
          • Swift + UIKit with Scenes
          • Swift + UIKit without Scenes
          • Objective-C with Scenes
          • Objective-C without Scenes
        • Create Custom Triggers
          • Capture Recording
          • Show the Introduction Screen
        • Update the SDK
        • Troubleshooting
      • Android
        • Overview
        • Install the SDK
        • Get your API Key
        • SDK Configuration
          • Kotlin
          • Java
        • Create Custom Triggers
          • Capture Recording
          • Show the Introduction Screen
        • Update the SDK
        • Troubleshooting
      • ReactNative
        • Install SDK for ReactNative iOS
        • Install SDK for ReactNative Android
        • Update the SDK
      • Flutter
        • Overview
        • Install the SDK
        • Get your API Key
        • SDK Configuration
        • Create Custom Triggers
          • Capture Recording
          • Show the Introduction Screen
      • In-app Surveys
        • Create Survey
        • Edit Survey
        • Launch Survey
        • Pause Survey
        • Survey Responses
        • Survey Styling
    • ⬅️FlightRecorder Home
Powered by GitBook
On this page
  1. SDK Documentation
  2. Pulse Labs FlightRecorder Documentation
  3. iOS
  4. SDK Configuration

Swift + SwiftUI

If your application is written in Swift and uses SwiftUI as the entry point to the UI, follow these steps: ​

  1. Open the main entry point of your application, which is annotated with @main and contains your App instance. ​

  2. Add the import PulseLabsFlightRecorderSDK statement to the top of the file:

    import SwiftUI
    
    // Insert the import statement:
    import PulseLabsFlightRecorderSDK
    
    @main
    struct MyApp: App {    
  3. Observe the scenePhase value in the Environment, if you are not already doing so, using @Environment(\.scenePhase) private var scenePhase indicated in the example below at (A). Then, check when the phase is .active using .onChange(of: scenePhase) and if phase == .active, as shown in the below example at (B) and (C). Finally, insert the FlightRecorderSDK.start(apiKey: "YOUR_API_KEY") line of code so that it runs whenever the ScenePhase becomes .active as shown below at (D), replacing "YOUR_API_KEY" with your own API key. There are also other parameters that are optionals: - customFontsLib: you can also create an instance of FlightRecorderCustomFontsLib as pass it here. The sdk then will use that font to decorate the native part of the feedback form

    import SwiftUI
    import PulseLabsFlightRecorderSDK
    
    @main
    struct MyApp: App {
    
        // A: Observe the scenePhase value in the Environment
        @Environment(\.scenePhase) private var scenePhase
    
        var body: some Scene {
            WindowGroup {
                MyRootView()
            }
            
            // B: add thhe .onChange
            .onChange(of: scenePhase) { phase in
                
                // C: Insert the check for phase .active
                if phase == .active {
                    
                    // D: Insert the SDK start function call, replacing YOUR_API_KEY with your API key
                    FlightRecorderSDK.start(
                        apiKey: "YOUR_API_KEY",
                        customFontsLib: FlightRecorderCustomFontsLib?
                    )
                }
            }
        }
    }

The SDK is now installed! Run your app on a real device (the SDK will not work in a simulator) and the introduction screen will appear on the first run. You can then shake or take a screenshot to capture the video content and send a report.

Last updated 2 months ago

If you have any issues, head to the section.

Troubleshooting