Last active
July 23, 2021 22:16
-
-
Save Rashidium/8d6728a873367452f11e016c9cf52761 to your computer and use it in GitHub Desktop.
AppDelegate with CustomerLinkRoutable conformance
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( | |
_ 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