Skip to content

Commit 98845b8

Browse files
committed
Add switch statement for various deep link options
1 parent 5e47309 commit 98845b8

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

Loop/AppDelegate.swift

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,26 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, WindowProvider {
9999
options: [UIApplication.OpenURLOptionsKey : Any] = [:] ) -> Bool {
100100

101101
// Process the URL.
102-
guard let components = NSURLComponents(url: url, resolvingAgainstBaseURL: true), components.host != "" else {
102+
guard let components = NSURLComponents(url: url, resolvingAgainstBaseURL: true), let linkTarget = components.host else {
103103
// No sub-path specified
104104
return true
105105
}
106106

107-
// Could be a case statement if more than one deep link defined
108-
if components.host == "carbs" {
109-
// Here we would call something like the function presentCarbEntryScreen defined in StatusTableViewController; not sure if that type of code has to all be copied here, or if those various functions (e.g. carb entry, bolus view, settings) should be put elsewhere, or could be repurposed from existing files.
107+
// Below examples would call something like the function presentCarbEntryScreen defined in StatusTableViewController; not sure if that type of code has to all be copied here, or if those various functions (e.g. carb entry, bolus view, settings) should be put elsewhere, or could be repurposed from existing files.
108+
109+
switch linkTarget.lowercased() {
110+
case "carbs" :
111+
// open carb entry view controller
112+
return true
113+
case "bolus" :
114+
// open bolus view controller
115+
return true
116+
case "settings" :
117+
// open settings view
118+
return true
119+
default :
120+
return true
110121
}
111-
return true
112122
}
113123

114124
}

0 commit comments

Comments
 (0)