This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension DeeplinkManager { | |
/// Returns linkable satisfied with the payload. | |
/// - Parameter payload: Push notification payload of the deeplink. | |
/// - Returns: Linkable satisfied with the payload. | |
public func getLinkable(payload: [AnyHashable: Any]) -> AppLinkable? { | |
for (index, link) in links.enumerated() { | |
guard let activeLink = link.getLinkable(payload: payload) else { continue } | |
links[index] = activeLink | |
return activeLink | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
var deeplinkManager: DeeplinkManager! | |
func application( | |
_ application: UIApplication, | |
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? | |
) -> Bool { | |
deeplinkManager = DeeplinkManager(supportedLinks: [CustomerLink()]) | |
} | |
@discardableResult func application( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct CustomerLink: AppLinkable { | |
public var customerNo: Int64! | |
init() { | |
} | |
init(customerNo: Int64) { | |
self.customerNo = customerNo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// AppLinkable's for deeplink navigation. | |
public protocol AppLinkable { | |
/// Returns AppLinkable if url is satisfied | |
/// - Parameter url: URL of deeplink | |
func getLinkable(_ url: URL) -> Self? | |
/// Returns OneLinkable if url is satisfied. | |
/// - Parameter payload: Push notification payload of the deeplink. | |
func getLinkable(payload: [AnyHashable: Any]) -> Self? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public protocol CustomerLinkRoutable: AppLinkRoutable { | |
func customerLinkRoute(_ link: CustomerLink) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Routing conformance for the Main scene. | |
public protocol AppLinkRoutable { | |
// Should be implemented for each link. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension AppLinkable { | |
func getLinkable(payload: [AnyHashable: Any]) -> Self? { | |
return nil | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// AppLinkable's for deeplink navigation. | |
public protocol AppLinkable { | |
/// Returns AppLinkable if url is satisfied | |
/// - Parameter url: URL of deeplink | |
func getLinkable(_ url: URL) -> Self? | |
/// Returns AppLinkable if url is satisfied. | |
/// - Parameter payload: Push notification payload of the deeplink. | |
func getLinkable(payload: [AnyHashable: Any]) -> Self? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// AppLinkable's for deeplink navigation. | |
public protocol AppLinkable { | |
/// Returns AppLinkable if url is satisfied | |
/// - Parameter url: URL of deeplink | |
func getLinkable(_ url: URL) -> Self? | |
} |
NewerOlder