Vernissage/Vernissage/SceneDelegate.swift

34 lines
1.1 KiB
Swift
Raw Normal View History

2022-12-31 16:31:05 +01:00
//
// https://mczachurski.dev
2023-04-09 20:51:33 +02:00
// Copyright © 2023 Marcin Czachurski and the repository contributors.
2023-03-28 10:35:38 +02:00
// Licensed under the Apache License 2.0.
2022-12-31 16:31:05 +01:00
//
import SwiftUI
2023-02-19 10:32:38 +01:00
import PixelfedKit
2022-12-31 16:31:05 +01:00
import OAuthSwift
2023-04-07 16:59:18 +02:00
import EnvironmentKit
import BackgroundTasks
2022-12-31 16:31:05 +01:00
2023-01-12 18:34:48 +01:00
class SceneDelegate: NSObject, UISceneDelegate {
2022-12-31 16:31:05 +01:00
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
2023-01-29 19:11:44 +01:00
guard let url = URLContexts.first?.url else {
return
}
2023-01-29 19:11:44 +01:00
if url.host == AppConstants.oauthCallbackPart {
OAuthSwift.handle(url: url)
2023-03-11 18:30:33 +01:00
} else if url.host == AppConstants.statusCallbackPart {
let statusId = url.string.replacingOccurrences(of: "\(AppConstants.statusUri)/", with: "")
if statusId.isEmpty == false {
ApplicationState.shared.showStatusId = statusId
}
2023-05-01 07:50:24 +02:00
} else if url.host == AppConstants.accountCallbackPart {
let accountId = url.string.replacingOccurrences(of: "\(AppConstants.accountUri)/", with: "")
if accountId.isEmpty == false {
ApplicationState.shared.showAccountId = accountId
}
2023-01-29 19:11:44 +01:00
}
2022-12-31 16:31:05 +01:00
}
}