Lifecycle & Recording

SDK setup (on application start)

Smartlook SDK setup needs to be called only once during an application’s lifetime and it should be called on application startup. There is no need to stop recording explicitly on application closure, SDK will stop itself automatically.

The best place to setup the SDK is in didFinishLaunchingWithOptions method of the ApplicationDelegate:

import Smartlook

func application(_ application: UIApplication, 
                 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

	let smartlookConfig = Smartlook.SetupConfiguration(key: "API_KEY")
	Smartlook.setupAndStartRecording(configuration: smartlookConfig)
  
	// Other initialization stuff
	return true
}
#import <Smartlook/Smartlook.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

	SLSetupConfiguration *slConfig = [[SLSetupConfiguration alloc] initWithKey:@"API_KEY"];
	[Smartlook setupAndStartRecordingWithConfiguration:slConfig];
  
	// Other initialization stuff
	return YES;
}

The easiest way of setting up the SDK is with setupAndStartRecording() method:

class func Smartlook.setupAndStartRecording(configuration: Smartlook.SetupConfiguration)
+ (void)setupWithConfiguration:(nonnull SLSetupConfiguration *)configuration;

It will set the SDK up and also start the recording. SDK can be setup without starting the recording using the following:

class func Smartlook.setup(configuration: Smartlook.SetupConfiguration)
+ (void)setupWithConfiguration:(nonnull SLSetupConfiguration *)configuration;

And then the recording can be started by calling:

class func startRecording()
+ (void)startRecording;

Setup configuration

Some recording parameters can be configured on setup:

Smartlook can be setup using and instance of SetupConfiguration object. The object has a mandatory apiKey property, other property values are optional.

Some of the parameters could be also set in your project settings in Smartlook portal. It is advisible to use the projects settings when available there and use this setup configuration for testing and evaluating only.

PropertyTypeDefault valueDescription
apiKeystring-The API key of the project. Set it in the object init(key:) initializator.
framerateint2Recorded video frame rate (allowed values between 2 and 10). Note that by setting this value settings from the dashboard will be overridden!
useAdaptiveFrameratebooltrueBy default, Smartlook adapts its recording framerate to the frequency of UI changes in order to lower its footprint in app performace. For details, see Screen Recording Quality.
renderingModeRenderingModenativeDefine the way SDK is going to capture screen image data.
renderingModeOptionRenderingModeOptionnoneFurther customize the rendering mode.
eventTrackingModes[EventTrackingMode]full trackingSets which types of events are tracking by Smartlook.
resetSessionboolfalseStart recording with new session.
resetSessionAndUserboolfalseStart recording with new session and reset user.
enableIntegrations[Integration]-Array of enabled 3rd party integrations.

Start and stop recording

Recording can be started or stopped at any time, the only requirement is that the SDK is set up.

class func startRecording()
class func stopRecording()
+ (void)startRecording;
+ (void)stopRecording;

🚧

stopRecording()

doesn't need to be called on application closure. Recording is stopped automatically.

Check if SDK is recording

Check if SDK is currently recording can be handy when using startRecording() and stopRecording() methods. Simply call:

class func isRecording() -> Bool
+ (BOOL)isRecording;

Reset session

Current session can be ended and a new session created by calling:

class func resetSession(resetUser: Bool)
+ (void)resetSessionAndUser:(BOOL)resetUser

If resetUser is set to true, SDK will create a new visitor during the reset. This is especially beneficial when a new user needs to be identified (typically after logout).

A new session can be created on SDK setup:

let setupConfig = Smartlook.SetupConfiguration(key: "API_KEY")
setupConfig.resetSession = true         // to reset just the session
setupConfig.resetSessionAndUser = true  // alternatively, to reset user and implicitly the session, too
Smartlook.setupAndStartRecording(configuration: setupConfig)
SLSetupConfiguration *slConfig = [[SLSetupConfiguration alloc] initWithKey:@"API_KEY"];
slConfig.resetSession = YES;         // to reset just the session
slConfig.resetSessionAndUser = YES;  // alternatively, to reset user and implicitly the session, too
[Smartlook setupAndStartRecordingWithConfiguration:slConfig];