Supports deep linking to Patreon settings

This commit is contained in:
Riley Testut
2019-09-19 14:43:26 -07:00
parent 00a7886941
commit 73c44c5e29
5 changed files with 75 additions and 1 deletions

View File

@@ -50,6 +50,11 @@ private let ReceivedApplicationState: @convention(c) (CFNotificationCenter?, Uns
appDelegate.receivedApplicationState(notification: name)
}
extension AppDelegate
{
static let openPatreonSettingsDeepLinkNotification = Notification.Name("openPatreonSettingsDeepLinkNotification")
}
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
@@ -90,6 +95,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
PatreonAPI.shared.refreshPatreonAccount()
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool
{
return self.open(url)
}
}
private extension AppDelegate
@@ -98,6 +108,18 @@ private extension AppDelegate
{
self.window?.tintColor = .altPrimary
}
func open(_ url: URL) -> Bool
{
guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false) else { return false }
guard let host = components.host, host.lowercased() == "patreon" else { return false }
DispatchQueue.main.async {
NotificationCenter.default.post(name: AppDelegate.openPatreonSettingsDeepLinkNotification, object: nil)
}
return true
}
}
extension AppDelegate