Skip to content

Instantly share code, notes, and snippets.

@Rashidium
Last active July 23, 2021 22:16
Show Gist options
  • Save Rashidium/1dea69f5c20b89dbe5d3cc34ac411a8e to your computer and use it in GitHub Desktop.
Save Rashidium/1dea69f5c20b89dbe5d3cc34ac411a8e to your computer and use it in GitHub Desktop.
DeeplinkManager
/// Manager for deeplinks.
public final class DeeplinkManager {
/// Application supported deeplinks.
private var links: [AppLinkable]
/// Initializes manager with supported links.
public init(supportedLinks links: [AppLinkable]) {
self.links = links
}
/// Returns linkable satisfied with the url.
/// - Parameter url: URL of the deeplink.
/// - Returns: Linkable satisfied with the url.
public func getLinkable(_ url: URL) -> AppLinkable? {
for (index, link) in links.enumerated() {
guard let activeLink = link.getLinkable(url) else { continue }
links[index] = activeLink
return activeLink
}
return nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment