iOS SDK - Initializing the SDK
Installation
Section titled InstallationThe following line will install the tracker and with it the SDK for you to take advantage of all tracker features.
Cocoapods
Section titled Cocoapodspod 'OpenReplay', '~> 1.0.5'
Swift Package Manager
Section titled Swift Package Managerdependencies: [
.package(url: "https://github.com/openreplay/ios-tracker.git", from: "1.0.5"),
]
Initialization
Section titled InitializationWhen instantiating OpenReplay’s tracker, there are several configuration options you can provide to customize many aspects of the recording and the recording experience. You must set the projectKey
option in the constructor. You can get this value from your OpenReplay dashboard under ‘Preferences > Projects’.
Adding the tracking code
Section titled Adding the tracking codeAdd the following code to your AppDelegate.swift
file:
// AppDelegate.swift
import OpenReplay
//...
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// not required if you're using our SaaS version
OpenReplay.shared.serverURL = "https://your.instance.com/ingest"
// check out our SDK docs to see available options
OpenReplay.shared.start(projectKey: "projectkey", options: .defaults)
// ...
return true
}
Setting up touches listener
Section titled Setting up touches listener// SceneDelegate.Swift
import OpenReplay
// ...
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
let contentView = ContentView()
.environmentObject(TodoStore())
if let windowScene = scene as? UIWindowScene {
let window = TouchTrackingWindow(windowScene: windowScene) // <<<< here
window.rootViewController = UIHostingController(rootView: contentView)
self.window = window
window.makeKeyAndVisible()
}
}
Sanitize Data
Section titled Sanitize DataSee how to sanitize data in iOS replays for more details.
Initialization Options
Section titled Initialization Optionscrashes: Bool
Enables crashlytics.analytics: Bool
Enables analytics tracking of marked views.performances: Bool
Enables performance listener.logs: Bool
Enables logs listener.screen: Bool
Enables screen recorder.wifiOnly: Bool
Forces tracker to start only if user has a wifi connection.
Methods
Section titled MethodsHave questions?
Section titled Have questions?If you have any questions about this process, feel free to reach out to us on our Slack or check out our Forum.