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
  • Select a Trigger and Capture Recording
  • Select a Trigger
  • Capture the recording from the Trigger
  1. SDK Documentation
  2. Pulse Labs FlightRecorder Documentation
  3. iOS
  4. Create Custom Triggers

Capture Recording

When you create project in the portal, it comes with the default triggers of Shake and ScreenGrab, so the SDK captures a recording when your user shakes the device or takes a screenshot - actions considered as triggers. You can extend this capability by incorporating your own additional triggers by creating another in the portal which will then have an action type of Custom.

For instance, you might want to capture a recording when your user presses a button in your app or completes a specific sequence.

However you capture the recording, the SDK user interface will always appear to let your users review the footage, edit and submit.

Select a Trigger and Capture Recording

Select a Trigger

Decide from what event you want to capture the video, for example a button press. We will call this the trigger. This very simple example shows a possible trigger - when a button is pressed in a SwiftUI app.

Swift
struct ContentView: View {
    var body: some View {
        VStack {
            Text("Hello, world!")

            Button(action: {
                self.buttonPressed()
            }) {
                Text("Press Me")
                    .padding()
                    .background(Color.blue)
                    .foregroundColor(.white)
                    .cornerRadius(10)
            }
        }
    }


    private func buttonPressed() {
        // This will be the trigger        
    }
}

Capture the recording from the Trigger

Place an import statement to import the SDK at the top of the file containing the trigger (the event which will trigger the capture of the recording). For example, this might be a View Controller, or a View. Note that we also provide the optional surveyName parameter here, so potentially if you have designed a number of different in-app surveys, then you can specify which one to show at different trigger points.

Swift
import PulseLabsFlightRecorderSDK
Objective-C
#import <PulseLabsFlightRecorderSDK/PulseLabsFlightRecorderSDK-Swift.h>

Call triggerCaptureRecording (Swift), triggerCaptureRecordingAndReturnError (Objective-C), at the moment you want to capture the video inside the trigger, handling any errors thrown:

Swift
do {
    try FlightRecorderSDK.triggerCaptureRecording()
} catch {
    // Handle the error if you wish (see note below)
}
Objective-C
NSError *error = nil;
[FlightRecorderSDK triggerCaptureRecordingAndReturnError:&error];
if (error) {
    NSLog(@"Error: %s", "FlightRecorderSDK not yet started, cannot capture recording.");
}

The only error the SDK throws is the FlightRecorderSDKError.failedToStart error. To effectively handle this error, consider logging it directly to the console, or alternatively, utilize your preferred logging framework.

If you do encounter the FlightRecorderSDKError.failedToStart error, it indicates that the triggerCaptureRecording function was called before initializing the FlightRecorderSDK with the start function.

Here is the completed SwiftUI example, completed by calling the method from the onButtonClick function:

Swift
struct ContentView: View {
    var body: some View {
        VStack {
            Text("Hello, world!")

            Button(action: {
                self.buttonPressed()
            }) {
                Text("Press Me")
                    .padding()
                    .background(Color.blue)
                    .foregroundColor(.white)
                    .cornerRadius(10)
            }
        }
    }


    private func buttonPressed() {
        // This will be the trigger
        do {
            try FlightRecorderSDK.triggerCaptureRecording()
        } catch {
            // Handle the error if you wish (see note below)
        }        
    }
}
PreviousCreate Custom TriggersNextShow the Introduction Screen

Last updated 2 months ago

To resolve this issue, ensure that you call FlightRecorderSDK.start during your application's initialization phase as shown in the section, before invoking any recording functions.

SDK Configuration