Skip to content

Commit da9b6b7

Browse files
authored
fix-swift-testbed-crash-DEVEX-327 (#817)
1 parent 6e94234 commit da9b6b7

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Branch-TestBed-Swift/TestBed-Swift/AppDelegate.swift

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, AdjustDelegate, AppsFlyer
7575

7676
// Required. Initialize session. automaticallyDisplayDeepLinkController is optional (default is false).
7777

78-
branch.initSession(launchOptions: launchOptions, automaticallyDisplayDeepLinkController: false, deepLinkHandler: { params, error in
78+
branch.initSession(
79+
launchOptions: launchOptions,
80+
automaticallyDisplayDeepLinkController: false,
81+
deepLinkHandler: { params, error in
7982

8083
defer {
8184
let notificationName = Notification.Name("BranchCallbackCompleted")
@@ -98,14 +101,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate, AdjustDelegate, AppsFlyer
98101
if clickedBranchLink {
99102
let nc = self.window!.rootViewController as! UINavigationController
100103
let storyboard = UIStoryboard(name: "Content", bundle: nil)
101-
let contentViewController = storyboard.instantiateViewController(withIdentifier: "Content") as! ContentViewController
104+
let contentViewController = storyboard.instantiateViewController(
105+
withIdentifier: "Content"
106+
) as! ContentViewController
102107
nc.pushViewController(contentViewController, animated: true)
103108

104-
let referringLink = paramsDictionary["~referring_link"] as! String
105-
let content = String(format:"\nReferring link: \(referringLink)\n\nSession Details:\n\(paramsDictionary.JSONDescription())")
109+
let referringLink = paramsDictionary["~referring_link"] as? String
110+
let content = String(
111+
format:"\nReferring link: \(referringLink ?? "<nil>")" +
112+
"\n\nSession Details:\n\(paramsDictionary.JSONDescription())"
113+
)
106114
contentViewController.content = content
107115
contentViewController.contentType = "Content"
108116
}
117+
109118
} else {
110119
print(String(format: "Branch TestBed: Finished init with params\n%@", paramsDictionary.description))
111120
}

0 commit comments

Comments
 (0)