Skip to content

Commit 894f888

Browse files
committed
feat(apple): Add session replay trouble shooting page with custom window handling
1 parent de97c17 commit 894f888

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: Troubleshooting
3+
sidebar_order: 5503
4+
notSupported:
5+
description: "Troubleshoot and resolve common issues with the iOS Session Replay."
6+
---
7+
8+
## Session Replay is not recording with custom window setup
9+
10+
If you have a custom window setup (e.g. multiple instances of `UIWindow`), you need to ensure that the Sentry SDK is able to find the correct window.
11+
12+
When using window scenes, make sure that the main window is assigned in your `UIWindowSceneDelegate`'s [`window` property](https://developer.apple.com/documentation/uikit/uiwindowscenedelegate/window).
13+
14+
```swift
15+
final class SceneDelegate: NSObject, UIWindowSceneDelegate {
16+
17+
var window: UIWindow?
18+
19+
func scene(
20+
_ scene: UIScene,
21+
willConnectTo session: UISceneSession,
22+
options connectionOptions: UIScene.ConnectionOptions
23+
) {
24+
guard let scene = scene as? UIWindowScene else { return }
25+
26+
// Configure your windows here, e.g.
27+
let mainWindow = UIWindow(windowScene: scene)
28+
mainWindow.rootViewController = UIViewController()
29+
mainWindow.makeKeyAndVisible()
30+
31+
// Do not forget to assign the window to the SceneDelegate's window property:
32+
self.window = mainWindow
33+
}
34+
}
35+
```
36+
37+
Alternatively, you can also create a custom proxy variable for the window:
38+
39+
```swift
40+
final class SceneDelegate: NSObject, UIWindowSceneDelegate {
41+
42+
var mainWindow: UIWindow?
43+
44+
func scene(
45+
_ scene: UIScene,
46+
willConnectTo session: UISceneSession,
47+
options connectionOptions: UIScene.ConnectionOptions
48+
) {
49+
guard let scene = scene as? UIWindowScene else { return }
50+
51+
// Configure your windows here, e.g.:
52+
mainWindow = UIWindow(windowScene: scene)
53+
mainWindow.rootViewController = UIViewController()
54+
mainWindow.makeKeyAndVisible()
55+
}
56+
57+
// This is required to make sure that the Sentry SDK can find the correct window:
58+
59+
var window: UIWindow? {
60+
get {
61+
return mainWindow
62+
}
63+
set {
64+
mainWindow = newValue
65+
}
66+
}
67+
}
68+
```

0 commit comments

Comments
 (0)