Show the Introduction Screen
The SDK displays the introduction screen during the very first app launch, considering this the trigger. This feature enables you to add extra triggers and also allows you to disable the default app launch trigger.
For instance, you may choose to present the introduction screen at the end of your onboarding screens or provide an option to show it again from a help menu.
Select a Trigger and Show the Introduction Screen
Select a Trigger
Decide from where you want to show the introduction screen. For example, at the end of your onboarding screens or when a button in a menu is pressed. We will call this the trigger. This simple example shows a possible trigger - when a button is pressed in a SwiftUI app.
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
}
}
Show the Introduction Screen 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 display of the introduction screen). For example, this might be a View Controller, or a View.
import PulseLabsFlightRecorderSDK
#import <PulseLabsFlightRecorderSDK/PulseLabsFlightRecorderSDK-Swift.h>
Call showIntroductionUI
(Swift), or showIntroductionUIWithDisplayOnlyOnce:error:
(Objective-C), at the moment you want to show the introduction screen inside the trigger, handling any errors thrown:
do {
try FlightRecorderSDK.showIntroductionUI(displayOnlyOnce: false)
} catch {
// Handle the error if you wish (see note below)
}
NSError *error = nil;
[FlightRecorderSDK showIntroductionUIWithDisplayOnlyOnce:false error:&error];
if (error) {
NSLog(@"Error: %s", "FlightRecorderSDK not yet started, cannot show introduction screen.");
}
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.
To resolve this issue, ensure that you call FlightRecorderSDK.start
during your application's initialization phase as shown in the SDK Configuration section, before invoking any further functions.
Here is the completed SwiftUI example, completed by calling the method from the onButtonClick function:
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.showIntroductionUI(displayOnlyOnce: false)
} catch {
// Handle the error if you wish (see note below)
}
}
}
Prevent the Introduction Screen from Showing on First Launch
If you do not wish to show the introduction screen when you first launch the app, follow the instructions for your language and framework.
SwiftUI
Navigate to the main entry point of your application, which is annotated with
@main
and contains yourApp
instance. Locate the code that starts the SDK by searching for
FlightRecorderSDK.start
.Set
automaticallyShowIntroduction: false
when starting the SDK as shown:FlightRecorderSDK.start(apiKey: "YOUR_API_KEY", automaticallyShowIntroduction: false)
Save your changes. The introduction UI will no longer show on first launch.
UIKit with Scenes
Navigate to the SceneDelegate file within your project.
Locate the code that starts the SDK by searching for
FlightRecorderSDK.start
.Set
automaticallyShowIntroduction: false
when starting the SDK as shown:FlightRecorderSDK.start(apiKey: "YOUR_API_KEY", automaticallyShowIntroduction: false)
[FlightRecorderSDK startWithApiKey:@"YOUR_API_KEY" automaticallyShowIntroduction:FALSE];
Save your changes. The introduction UI will no longer show on first launch.
UIKit without Scenes
Navigate to the AppDelegate file within your project.
In the
applicationDidBecomeActive(_:)
method, locate and delete the following lines depending on the language you are using:showIntroductionUI(displayOnlyOnce: true)
NSError *error = nil; [FlightRecorderSDK showIntroductionUIWithDisplayOnlyOnce:true error:&error]; if (error) { NSLog(@"Error: %s", "FlightRecorderSDK not yet started, cannot show introduction screen."); }
Save your changes. The introduction UI will no longer show on first launch.
Last updated