mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
36 lines
798 B
Swift
36 lines
798 B
Swift
|
|
import Foundation
|
||
|
|
|
||
|
|
public enum DeepLink {
|
||
|
|
case webAppLinkRequest(requestID: String)
|
||
|
|
}
|
||
|
|
|
||
|
|
public extension DeepLink {
|
||
|
|
var linkRequestID: String? {
|
||
|
|
if case let DeepLink.webAppLinkRequest(requestID) = self {
|
||
|
|
return requestID
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
static func make(from url: URL) -> DeepLink? {
|
||
|
|
if url.scheme == "omnivore" {
|
||
|
|
return deepLinkFromOmnivoreScheme(url: url)
|
||
|
|
}
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
private static func deepLinkFromOmnivoreScheme(url: URL) -> DeepLink? {
|
||
|
|
switch url.host {
|
||
|
|
case "shareExtensionRequestID":
|
||
|
|
let requestID = url.path.replacingOccurrences(of: "/", with: "")
|
||
|
|
return .webAppLinkRequest(requestID: requestID)
|
||
|
|
default:
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Example deep links
|
||
|
|
// "omnivore://shareExtensionRequestID/sampleRequestID"
|