Skip to content

Instantly share code, notes, and snippets.

@Rashidium
Last active July 23, 2021 22:16
Show Gist options
  • Save Rashidium/8d6728a873367452f11e016c9cf52761 to your computer and use it in GitHub Desktop.
Save Rashidium/8d6728a873367452f11e016c9cf52761 to your computer and use it in GitHub Desktop.
AppDelegate with CustomerLinkRoutable conformance
@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(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
if let link = deeplinkManager.getLinkable(url) {
link.link(from: self)
return true
}
}
func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void
) {
if let link = deeplinkManager.getLinkable(payload: response.notification.request.content.userInfo) {
link.link(from: self)
}
completionHandler()
}
}
extension AppDelegate: CustomerLinkRoutable {
public func customerLinkRoute(_ link: CustomerLink) {
// Route to customer detail with the attributes of `link`.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment