Skip to content

Commit 5979f87

Browse files
authored
Merge pull request #611 from mindbox-cloud/feature/WMSDK-511-SceneDelegate-and-Example-update
WMSDK-511: Remove the `UIWindow` possession from `MindboxSceneDelegate` and update the Example to use `MindboxSceneDelegate`
1 parent 6b98e4d commit 5979f87

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

Example/Example.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,14 +461,10 @@
461461
inputFileListPaths = (
462462
"${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-frameworks-${CONFIGURATION}-input-files.xcfilelist",
463463
);
464-
inputPaths = (
465-
);
466464
name = "[CP] Embed Pods Frameworks";
467465
outputFileListPaths = (
468466
"${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-frameworks-${CONFIGURATION}-output-files.xcfilelist",
469467
);
470-
outputPaths = (
471-
);
472468
runOnlyForDeploymentPostprocessing = 0;
473469
shellPath = /bin/sh;
474470
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-frameworks.sh\"\n";

Example/Example/AppDelegate.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ final class AppDelegate: MindboxAppDelegate {
5757
) {
5858
// https://developers.mindbox.ru/docs/ios-sdk-methods
5959
print("Is mindbox notification: \(Mindbox.shared.isMindboxPush(userInfo: response.notification.request.content.userInfo))")
60-
if let mindboxPushNotification = Mindbox.shared.getMindboxPushData(userInfo: response.notification.request.content.userInfo),
61-
Mindbox.shared.isMindboxPush(userInfo: response.notification.request.content.userInfo),
60+
if Mindbox.shared.isMindboxPush(userInfo: response.notification.request.content.userInfo),
61+
let mindboxPushNotification = Mindbox.shared.getMindboxPushData(userInfo: response.notification.request.content.userInfo),
6262
let uniqueKey = mindboxPushNotification.uniqueKey {
6363
Mindbox.shared.pushClicked(uniqueKey: uniqueKey)
6464
}

Example/Example/SceneDelegate.swift

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,37 @@
88

99
import UIKit
1010
import SwiftUI
11+
import Mindbox
1112

12-
final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
13+
final class SceneDelegate: MindboxSceneDelegate {
1314

1415
var window: UIWindow?
1516

16-
func scene(
17+
override func scene(
1718
_ scene: UIScene,
1819
willConnectTo session: UISceneSession,
1920
options connectionOptions: UIScene.ConnectionOptions
2021
) {
22+
super.scene(scene, willConnectTo: session, options: connectionOptions)
23+
2124
guard let windowScene = (scene as? UIWindowScene) else { return }
2225
let window = UIWindow(windowScene: windowScene)
2326
let viewModel = MainViewModel()
2427
window.rootViewController = UIHostingController(rootView: MainView(viewModel: viewModel))
2528
self.window = window
2629
window.makeKeyAndVisible()
30+
31+
// Handle Universal Link on a cold start:
32+
// The app was launched from a URL (not already running).
33+
// Read the link from `connectionOptions.userActivities` and route to the right screen.
34+
}
35+
36+
// https://developers.mindbox.ru/docs/universal-links#ios
37+
override func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
38+
super.scene(scene, continue: userActivity)
39+
40+
// Handle Universal Link on a warm start:
41+
// The app is already running (foreground or background) and receives a new URL.
42+
// Use `scene(_:continue:)` to parse and route the link.
2743
}
2844
}

Mindbox/MindboxSceneDelegate.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ import UIKit
99

1010
@available(iOS 13.0, *)
1111
open class MindboxSceneDelegate: UIResponder, UIWindowSceneDelegate {
12-
open var window: UIWindow?
1312

1413
open func scene(
1514
_ scene: UIScene,
1615
willConnectTo session: UISceneSession,
1716
options connectionOptions: UIScene.ConnectionOptions
1817
) {
1918
Mindbox.shared.track(.launchScene(connectionOptions))
20-
guard (scene as? UIWindowScene) != nil else { return }
2119
}
2220

2321
open func scene(

0 commit comments

Comments
 (0)